Camera Script doesn't always work

Hello!
So I have a camera script that sets the players camera to Scriptable when they join. However, 1/5 of the time, it doesn’t set! Is scriptable prints, but the camera follows the player, and the cframe doesn’t change!
Local Script:

local Camera = workspace.CurrentCamera
local RS = game:GetService('ReplicatedStorage')

wait(2)


repeat 
	Camera.CameraType = Enum.CameraType.Scriptable 
	wait()
until Camera.CameraType == Enum.CameraType.Scriptable

print('is scriptable')

Camera.CFrame = workspace:WaitForChild('CameraPart').CFrame

(In StarterPlayerScripts)

I get no errors! Thanks for any help!

I quite don’t understand why you need this:

repeat 
	Camera.CameraType = Enum.CameraType.Scriptable 
	wait()
until Camera.CameraType == Enum.CameraType.Scriptable

Cant it just be:

Camera.CameraType == Enum.CameraType.Scriptable

Try to put wait before the variables and for the camera use WaitForChild()

1 Like

That just causes an infinite yield for the camera.

that’s because CurrentCamera is a property, not an object, l0l

repeat wait() until workspace.CurrentCamera ~= nil

There you go