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

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

Asked by
tjtorin 172
5 years ago

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)
0
ew don't use wait() as a condition and that wait time is ridiculous and will only wait about 0.029 seconds User#19524 175 — 5y
0
yes ik tjtorin 172 — 5y

1 answer

Log in to vote
1
Answered by
Launderer 343 Moderation Voter
5 years ago

RenderStepped is better amigo.

local RunService = game:GetService("RunService")

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

Answer this question