Unlocking mouse in forced first person mode

Is it possible for me to unlock the mouse in a game which forces first person? I mainly need to do this to make GUI interactions much easier, but haven’t been able to find any way of doing it yet.

9 Likes

Hello there.
GUI buttons have a property called “Modal”, which releases the mouse lock in first person mode when the button is set to visible.
Desc in API reference: GuiButton | Documentation - Roblox Creator Hub

37 Likes

Awesome, thanks! I’m pretty new to GUI making so this is super useful to know about. :+1:

2 Likes

If you want your mouse to be unlocked regardless of whether there’s a GUI present or not, you could also place the following in a local script under StarterPlayerScripts:

local player = game.Players.LocalPlayer
local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindAction(
	"Action",
	function ()
		return Enum.ContextActionResult.Sink
	end,
	false,
	Enum.UserInputType.MouseWheel
)

player.CharacterAdded:Connect(function()
	local plrGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

    local screenGui = Instance.new("ScreenGui", plrGui)
 
	local txtButton = Instance.new("TextButton")
	txtButton.BackgroundTransparency = 1
	txtButton.Size = UDim2.new(0, 0, 0, 0)
    txtButton.Text = " "

	txtButton.Modal = true
	 
	txtButton.Parent = screenGui
end)
28 Likes