ViewportCharacterSync
Key RequiredUniversal

ViewportCharacterSync

Universal ScriptGaze_Gaze_ 2K views 6 executesUpdated Mar 8, 2025
5.0/ 5(3 votes)
30100% Positive
Lua Script•65 lines (2174 chars)
local p=game:GetService("Players")  
local r=game:GetService("RunService")  
local lp=p.LocalPlayer  
local cam=workspace.CurrentCamera  
local rs,gui,vpf  

local function stop()  
if rs then rs:Disconnect()rs=nil end  
if gui then gui:Destroy()gui,vpf=nil,nil end  
end  

local function init()  
if not lp.Character then return end  
local c=lp.Character  
local hrp=c:FindFirstChild("HumanoidRootPart")or c:WaitForChild("HumanoidRootPart",5)  
if not hrp then return end  
c.Archivable=true  
local clone=c:Clone()  
local hrpClone=clone:FindFirstChild("HumanoidRootPart")  

for _,v in ipairs(c:GetDescendants())do if v:IsA("BasePart")or v:IsA("Decal")then v.Transparency=1 end end  
if hrpClone then hrpClone.Transparency=1 end  
stop()  

gui=Instance.new("ScreenGui")  
gui.IgnoreGuiInset=true  
gui.Parent=game:GetService("CoreGui")  

vpf=Instance.new("ViewportFrame")  
vpf.Size=UDim2.new(1,0,1,0)  
vpf.BackgroundTransparency=1  
vpf.CurrentCamera=cam  
vpf.Parent=gui  
clone.Parent=vpf  

c.DescendantRemoving:Connect(function(v)  
local cp=clone:FindFirstChild(v.Name,true)  
if cp then cp:Destroy()end  
end)  

c.AncestryChanged:Connect(function(_,p)if not p then stop()end end)  

rs=r.RenderStepped:Connect(function()  
if not c.Parent or not hrp or not clone.PrimaryPart then return end  
clone:SetPrimaryPartCFrame(c:GetPrimaryPartCFrame())  

for _,v in ipairs(c:GetDescendants())do if v:IsA("BasePart")then  
local cp=clone:FindFirstChild(v.Name)  
if cp then cp.CFrame=v.CFrame end end end  

for _,a in ipairs(c:GetChildren())do if a:IsA("Accessory")then  
local ac=clone:FindFirstChild(a.Name)  
if ac and ac:FindFirstChild("Handle")and a:FindFirstChild("Handle")then ac.Handle.CFrame=a.Handle.CFrame end end end  

local z=(cam.CFrame.Position-cam.Focus.Position).Magnitude  
local t=z<3 and math.clamp(1-(z/3),0,1)or 0  

for _,v in ipairs(clone:GetDescendants())do if v:IsA("BasePart")or v:IsA("Decal")then v.Transparency=t end end  
if hrpClone then hrpClone.Transparency=1 end  
end)  
end  

lp.CharacterAdded:Connect(function()stop()task.wait(0.5)init()end)  
lp.CharacterRemoving:Connect(stop)  
if lp.Character then task.wait(0.5)init()end

Features & Information

Just playing around with cameraviewport

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts