Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I stop players from rotating their character with mouse or keys?

Basically I just don't want the player to be able to rotate their camera. I've tried setting the CFrame of the camera in a loop but that stops any movement at all.

Can't seem to find a good solution.

2 answers

✓ Accepted answer

If you wish to only edit camera movement, replace the default CameraScript with the following code (in other words, insert the following into a LocalScript named CameraScript parented under the StarterPlayerScripts folder):

RunService = game:GetService("RunService")
player = game.Players.LocalPlayer
camera = workspace.CurrentCamera
character = nil

rotation = Vector3.new() --set the defualt camera rotation (must be in degrees)
offset = Vector3.new() --set the distance the camera should be from the players head

player.CharacterAdded:connect(function(char)
	character = char
end)
RunService:BindToRenderStep("Camera", 200, function()
	if character and character.Head then
		camera.CFrame = character.Head.CFrame+CFrame.new(offset)*CFrame.Angles(Vector3.new(math.rad(rotation.X), math.rad(rotation.Y), math.rad(rotation.Z)))
	end
end)

I didn't test the script, but it should work.

game:GetService("ContextActionService"):UnbindAllActions()

This discussion is preserved as it was. New answers, comments, and votes are closed.