Cursor in Gui not working with First Person

I’m making a game that is only in first person, however, when I try and move the cursor to click a Gui I can’t. Is there a way to fix this?

Any help is appreciated!

I’m not an expert on the matter, but I believe that setting the modal property to true in all of your gui elements should help. See here: GuiButton | Roblox Creator Documentation

1 Like

The mouse position can be locked to the center of the screen using MouseBehavior. Setting this property to Enum.MouseBehavior.LockCenter will lock the mouse to the center of the screen, Enum.MouseBehavior.Default will unlock the mouse.

If the mouse is locked, InputChanged will still fire when the player moves the mouse and will pass in the distance the mouse has moved.

local UserInputService = game:GetService("UserInputService")

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
    if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
        print("delta is (" .. tostring(inputObject.Delta.x) .. ", " ..  tostring(inputObject.Delta.y) .. ")")
--All of this will lock the mouse in the center and will tell you the delta

If you want the mouse to be unlocked then use :

local UserInputService = game:GetService("UserInputService")
 UserInputService.MouseBehavior = Enum.MouseBehavior.Default

If you found my answer helpful, be sure to mark it as the solution! :white_check_mark:

1 Like

Sorry for the late response, but this would work perfectly if my game was in 3rd person. Unfortunately it’s not, so how do you think I can combat this?

Actually, I got it working with this! Thank you for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.