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

How do I lock player camera Y rotation?

Asked by 4 years ago

So uh I made game, where you can change your camera person with X numpda, and third person doesn't has right mouse movement

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindActionAtPriority("RightMouseDisable", function()
    return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.Medium.Value, Enum.UserInputType.MouseButton2)

i made it cause the camera is "follow", but there is a bit problem, you can move your camera in first person and when you move it to up, it third person you wont see nothing but the sky, so i want it to lock Y rotation at the center, so whenever you click X, in third person, it will always look at center even if you moved your camera in first person.

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local toggle = false
local text = script.Parent
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.X then
    if toggle == false then
        player.CameraMode = "LockFirstPerson"
        text.Text = "Press X for Third Person"
        humanoid.CameraOffset = Vector3.new(0,0,0)
        toggle = true
    else
        toggle = false
        text.Text = "Press X for First Person"
        humanoid.CameraOffset = Vector3.new(2,0,0)
        player.CameraMode = "Classic"
    end
end
end)

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago

Simply, just edit the default camera module.

Ad

Answer this question