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
6 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.

01local Player = game.Players.LocalPlayer
02local Character = Player.Character or Player.CharacterAdded:Wait()
03local Camera = game.Workspace.CurrentCamera
04 
05Camera.CameraType = Enum.CameraType.Scriptable
06wait(.3)
07 
08if Camera.CameraType ~= Enum.CameraType.Scriptable then
09    print(false)
10    Camera.CameraType = Enum.CameraType.Scriptable
11else
12    print(true)
13end
14 
15spawn(function()
16    while wait(.0000000001) do
17        Camera.CFrame = game.Workspace.LocalCam.CFrame
18    end
19end)
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 — 6y
0
yes ik tjtorin 172 — 6y

1 answer

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

RenderStepped is better amigo.

1local RunService = game:GetService("RunService")
2 
3while RunService.RenderStepped:Wait() do
4    Camera.CFrame = game.Workspace.LocalCam.CFrame
5end
Ad

Answer this question