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

How to let mouse move freely in a gui?[Solved]

Asked by 6 years ago
Edited 6 years ago

My game forces first person, so the mouse is locked in the middle of the screen. However, I would like to add a shop gui. The gui is pretty much useless when the mouse is stuck in the middle of the screen and can't click the buttons. I want to try to avoid making a keybind for every button in the gui. Is there any way I can simply let the mouse move freely while keeping the player in first person? Thanks in advanced

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

[Edit - I like your solution better, but didn't fully read your comment until after I posted this. I'll leave this here as an alternative.] You can have a GuiButton in your GUI with the Modal property enabled. If you don't use GuiButtons, you can add an invisible one (that is, it can have a Size of UDim2.new(0,0,0,0) to be invisible; it has to have Visible set to true).

You could have a button to activate/deactivate the mouse, which could simply toggle this button's Modal property.

0
By the way, if you've fixed your problem, it's good practice to edit your question's title to specify that it's been fixed/solved. chess123mate 5873 — 6y
0
Thanks, I've edited the title. It turns out Modal is actually a better alternative to what I had in mind. I thought that property meant you could move your mouse freely only over the button, but it turns out it's over the whole screen while Modal is true. Thanks! cowsoncows 951 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

In the force first person script make it were if a GUI is enabled then disable the force script then If the GUI is not enabled then make force first person enabled.

If you like for me to give a script for an example, please edit your question and add the force first person script. Thank you!

1
That isn't exactly what I was looking for, as then the player's character will be visible and I don't want that. However I did find what I was looking for, it's this: UserInputService.MouseBehavior = Enum.MouseBehavior.Default. That will keep them in first person and let the mouse move around until I set it back to LockCenter. Thanks for your help! cowsoncows 951 — 6y

Answer this question