Camera script not working

Anyone know why this script doesn’t work? I’m kind of a newbie to camera related stuff so I’d appreciate any help. (Yes it’s in a localscript)

local camera = workspace.CurrentCamera

repeat wait() camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
if #game.Players:GetChildren() == 1 then
camera.CFrame = workspace.BlueCamera.CFrame
else
camera.CFrame = workspace.RedCamera.CFrame
end

is that a server script or local script? are there any errors?

1 Like

As I said, yes it’s a local script. No there are no errors. Also I forgot to say that the script works sometimes, but it breaks a lot. I would say that there’s about like a 60% chance of it working for some reason.

1 Like

The camera script had probably loaded after your script runs. Maybe add a short delay on your script before changing the camera CFrame?

1 Like

I ran your code in an empty baseplate and it seem to work all fine, try adding prints to your code and see where it runs until it stops working

1 Like

I tried using LocalPlayer.CharacterAdded:Wait() but that just made the chance of it working worse. Probably zero.

1 Like