Camera does not switch to Scriptable

I am trying to fix a bug where CurrentCamera.CameraType will not switch to Enum.CameraType.Scriptable. Instead, it switches to Enum.CameraType.Custom… The problem however is that I do not know why this is happening. The only pattern that I have found is that it often happens when there is some user input from the start.

Player.CharacterAdded.Connect(function(character)
	humanoidRootPart = character.WaitForChild("HumanoidRootPart") as BasePart;
	
	-- Make the camera scriptable
	currentCamera.CameraType = Enum.CameraType.Scriptable;
	
	print(currentCamera.CameraType) -- Enum.CameraType.Custom???
end)

Also, I found this code on the Developer Hub. It is unclear to me why this is necessary and it seems like a very ugly way to keep the camera type on scriptable.

RunService.RenderStepped:Connect(function()
	if camera.CameraType ~= Enum.CameraType.Scriptable then
		camera.CameraType = Enum.CameraType.Scriptable
	end
end)

Is there a clean way to simply change and keep a Camera’s CameraType at scriptable?

This is a known issue, most devs keep attempting to change the CameraType until it’s set to Scriptable:

repeat 
	currentCamera.CameraType = Enum.CameraType.Scriptable 
	task.wait(.5) 
until currentCamera.CameraType == Enum.CameraType.Scriptable
3 Likes

Your approach only worked for a task.wait() of ~0.5 seconds. Maybe this solution is a bit cleaner. This way, I can wait and keep track until it actually changed.

2 Likes

Necro bump because this is the first result on Google!

Hey this is currently not working for me, however I found out that the camera starts as Fixed since the game starts, then switches to Custom (For me).

So what I did is run task.wait() until it’s NOT Fixed, then switched to Scriptable and there it is.

coroutine.wrap(function()
	local currentCamera = workspace.CurrentCamera
	repeat
		task.wait() 
	until currentCamera.CameraType ~= Enum.CameraType.Fixed
	currentCamera.CameraType = Enum.CameraType.Scriptable
end)()

Take into account that it switches after a couple frames, in my computer it takes anywhere from 2 to 4 frames to turn (Console logs Fixed x2, x3 or x4) Then it switches AND the camera will stay in the origin. If I wait 1 more frame, then the camera goes exactly to where it’s supposed to start from (Behind the player or inside their head for FPS).

That’s why this fix is not working, because it actually changes to Scriptable but is overriden later on.

Edit: This fix sometimes works, probably because the time between frames changes depending on configuration and your computer current workload. As this is not always reliable I will stick to my solution that is working 100% of the time (At the moment).

1 Like

Thank you. This known issue has still never been fixed by Roblox Staff. This is the perfect way to work around it.