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

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

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.

1 comment

2 answers

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

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