Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Viewport troubles showing character model help?

Asked by 4 years ago

Basically I am new to using viewports and am making it try to show the player but also update the players looks. Code. It is in a local script inside the viewport

local Viewport = script.Parent
local player = game.Players.LocalPlayer
local Charact = player.Name
local Character = game.Workspace:WaitForChild(Charact)
script.Parent.body.HumanoidRootPart.CFrame = game.Workspace.Angles.CharArea.HumanoidRootPart.CFrame
local Cam = Instance.new("Camera")
Cam.Name = "Vyam"
Cam.Parent = game.Workspace
Cam.CFrame = CFrame.new(-84.51, 114.878, -271.133) *CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))
wait(2)
script.Parent.CurrentCamera = Cam
function update()
    local player1 = game.Players.LocalPlayer
local CharacterM = player1.Character:Clone()
local Current = script.Parent.body
CharacterM.HumanoidRootPart.CFrame = Current.HumanoidRootPart.CFrame
Current:Destroy()
CharacterM.Name = "body"
CharacterM.Parent = script.Parent
end

for i,v in pairs(Character:GetChildren()) do
    v.Changed:Connect(function()
        if v:IsA("BasePart") then
        update()
        end
    end)

end

Basically I just want know why it does not update at all. Also I think it would be better if I made it update at a time interval instead of a part being changed. (This will reduce lag majorly)

Answer this question