Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The script makes character look glitchy?

I wanted to set a camera that is behind the character (like third person shooter camera) And it worked... kinda. The character movement isnt smooth and so is the camera. Please help if i miss something in the script.

game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Scriptable"
local target = game.Players.LocalPlayer.Character.Humanoid.Torso
local camera = workspace.CurrentCamera
while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position)
							* CFrame.new(2, 2, 3)
end

1 answer

✓ Accepted answer

It seems as you're using a while loop which is not fast enough to update on time. Try using the RunService to run that loop every render step or every frame like this:

game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Scriptable"
local target = game.Players.LocalPlayer.Character.Humanoid.Torso
local camera = workspace.CurrentCamera
game:GetService("RunService").RenderStepped:Connect(function()
    camera.CoordinateFrame = CFrame.new(target.Position)
                            * CFrame.new(2, 2, 3)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.