How can I make the player not be able to move their camera up or down

What I’m trying to do is make the camera not being able to move up or down, I don’t mess with the camera often however here is my current script which is a LocalScript inside the StarterGui.

cam = workspace.CurrentCamera

while true do
wait()
	-- here is where I'm stuck, I have no idea how to prevent the player from looking up or down.
end

Thank you for reading and hopefully replying.

If you use a script to set the CameraType property of workspace.CurrentCamera then you should be able to find a way to make the camera how you want. To make your time more efficient, go to the Camera in workspace when you aren’t testing and set the camera type until you find it perfect.

Clarification, you want the camera’s position to move with the player and just be able to be rotated around the player?

To put it in better words that I should have said first was that I have LockFirstPerson on and I want the player to be able to look horizontally, but not vertically

I have tried this just now and none of the CameraTypes have this ability, one has the ability to stop the camera movement horizontally but keeps it vertically which is the opposite of what I need and another just removes both horizontally and vertically

You could change the camera’s cframe angles to only have the Y value every runservice frame.

Could you explain to me how to do this, I know how to use run service but I don’t know much about Camera CFrame.

local x,y,z = Cam.CFrame:ToEulerAnglesXYZ()
Cam.CFrame = CFrame.new(Cam.CFrame.Position) * CFrame.Angles(0,y,0)

put that in renderstepped

4 Likes