How do i make the players camera be set to a part

What im looking for.

i made a animation that a player polls down a lever.
and i want the players camera to lock on to the players head.
with both Position and rotation.

im not looking for this:

while wait() do

	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	workspace.CurrentCamera.CFrame = humanoid.Parent.Head.CFrame

end)

the reason is because it jitters and doesnt look smooth and clean as how i would like it.

1 Like

bind it to a renderstep loop instead of a while wait() do loop:

local RunService = game:GetService("RunService")

local function onLeverPullAnimation()
	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	
	RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value + 3, function()
		workspace.CurrentCamera.CFrame = humanoid.Parent.Head.CFrame
	end)
end

Also make sure you are running this code on the client, things that need to run in a constant loop like camera transformations should always be done the client.

how do i end the render step, i want to see if a value is set to true and if it is to stop it!, also thanks!

RunService:UnbindFromRenderStep("CameraUpdate")
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.