Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago
game:GetService("ContextActionService"):UnbindAllActions()

Answer this question