Prevent Camera From Moving Around

So I’m making a main menu for my game and I want to prevent the camera from moving around while still being able to move my mouse around. Cant seem to figure it out even thought I looked at alot of places.

You’ll want to set the CameraType to Scriptable. You can achieve this by doing:

local camera = workspace.CurrentCamera

repeat -- Pcalled since assuming that you're immediately setting the CameraType when joining, it may not set right away due to a core script overriding it.
	wait()
	local success = pcall(function()
		camera.CameraType = Enum.CameraType.Scriptable
	end)
until success 

Seeing how you want to use it for the main menu, you can also set the CFrame of the camera as well. If you want to return your camera back to normal, just simply change the CameraType property to default.

1 Like

This won’t work properly, since success can’t be used outside of the repeat loop. Try this instead:

local camera = workspace.CurrentCamera
local success = false --see how the variable is here?

repeat
	wait()
	success = pcall(function()
		camera.CameraType = Enum.CameraType.Scriptable
	end)
until success
1 Like

The variable doesn’t have to be declared outside of the loop, especially for a pcall, as the success variable exists within the scope inside of the loop which is being accessed. There is no need to reference if the thread ran successfully outside of the scope in this scenario.

1 Like