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

How to fix inconsistent camera CFrame?

Asked by 2 years ago

I am trying to set the camera of the game on a fixed position and rotate around itself. The problem is every time I run the game the camera either ends up in the position I set or some other position which is the same but the y value is a random negative number instead of 10. The rotation works fine but I can’t understand why the script doesn’t work… and yes no other script is changing the camera’s position.

local camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer

camera.CameraType = Enum.CameraType.Scriptable
camera:GetPropertyChangedSignal("CameraType"):Wait()
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(0,10,0)
game:GetService("RunService").Heartbeat:Connect(function(dt)
    camera.CFrame = camera.CFrame * CFrame.Angles(0,math.rad(1)*dt*60,0)
end)
0
I saw another post like this. The solution was to add the line plr.Character.ChildAdded("Humanoid"):Wait() before the camera modifying lines. XRed03 17 — 2y
0
Thank you for helping but this code gives an error... ChildAdded cant be used for a specific instance but I basically used WaitForChild("Humanoid") and it didnt really change iraklisonic354 13 — 2y

Answer this question