I have a RenderStepped function that keeps the MouseBehavior locked at center because that's the only way it seems to work for me in-game. But i'm trying to figure out a way to disable it and re-enable it so the player can access in-game guis
main.run.RenderStepped:Connect(function() main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter end)
You could also try disconnecting.
local function myfunction () main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter end local connection = main.run.RenderStepped:Connect(myfunction) --connection:Disconnect
All you need is to add a check
with a bool
value that you change whenever you want the mouse to be free.
Something that looks like this
local inGui = false main.run.RenderStepped:Connect(function() if not inGui then main.uis.MouseBehavior = Enum.MouseBehavior.LockCenter end end)
Now let us say you want to make the mouse free again to be able to access the UIs
All you need to do is run this line:
inGui = true
Then when you want it locked again run this line:
inGui = false
That's it, if you have any questions please let me know.