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

How do I make my camera move smoothly when attached to a part?

I have a simple car and then there is a part called LocalCam which has a WeldConstraint on the car and I want the camera to be at the same position as that part and in my script I know why it is not smooth but I just do not know any other ways to fix it.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable
wait(.3)

if Camera.CameraType ~= Enum.CameraType.Scriptable then
	print(false)
	Camera.CameraType = Enum.CameraType.Scriptable
else
	print(true)
end

spawn(function()
	while wait(.0000000001) do
		Camera.CFrame = game.Workspace.LocalCam.CFrame
	end
end)

2 comments

0

ew don't use wait() as a condition and that wait time is ridiculous and will only wait about 0.029 seconds

0

yes ik

1 answer

✓ Accepted answer

RenderStepped is better amigo.

local RunService = game:GetService("RunService")

while RunService.RenderStepped:Wait() do
	Camera.CFrame = game.Workspace.LocalCam.CFrame
end

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