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

How do i unlock the mouse while in First Person Mode?

Asked by 10 years ago

I'm working on a little FPS, i want to be able to move my mouse in FPS mode but only when i press "ALT" so i can click GUIs and then lock my mouse back into place when i hit "ALT" again. This game is strictly a First Person game, not a single hint of Third Person.

(BASE SCRIPT)

game.Players.PlayerAdded:connect(function(player)
player.CameraMode = Enum.CameraMode.LockFirstPerson
end)

I want the camera to be able to stay in first person mode and lock and unlock the mouse by pressing ALT or any other Key.

2 answers

Log in to vote
0
Answered by 10 years ago

In a local script inside PlayerGui

local pressed = false
local Player =  game.Players.LocalPlayer
local mouse = Player:GetMouse
game.Players.PlayerAdded:connect(function(player)
    player.CameraMaxZoomDistance = 0
end
mouse.KeyDown:connect(function(key)
    if key == string.char(3) or key == string.char(4) then
        if pressed == false then
            player.CameraMaxZoomDistance = 0
`       elseif pressed = true then
            player.CameraMaxZoomDistance = -- normal Zoom distance
        end
    end
end
Ad
Log in to vote
-3
Answered by
Kyokamii 133
10 years ago

+raspyjessie Didnt work for me.

Answer this question