I had problems with getting MouseBehavior.LockCenter to work in my game so I decided to open up a new workspace and test things out there.
This is my code:
local UiS = game:GetService("UserInputService")
local RunS = game:GetService("RunService")
wait(5)
RunS.RenderStepped:Connect(function()
if UiS.MouseBehavior ~= Enum.MouseBehavior.LockCenter then
UiS.MouseBehavior = Enum.MouseBehavior.LockCenter
print(UiS.MouseBehavior)
end
end)
When I run a simulation it seems to run perfectly fine and it returns MouseBehavior.LockCenter.
On the other hand, when I try to run a test server with two players it returns MouseBehavior.Default and LockCenter ends up not working.
I’ve been looking through the Forum and Google to get answers, but I am kind of new to studio and scripting so I need more so I can understand.
From what I’ve seen it is either:
-
Still a bug that’s been going on for a long time and still trying to get fixed
-
Could be something in the PlayerModule’s CameraModule script that is causing it to be reset to Default. (If it is this can someone explain how to fix it or adjust it?)
-
I am on a Mac and I saw that LockCenter has a problem with the Mac Mouse base on this post. The thing with this post is that it is from 2017 so I doubt it is relevant, but I still would like to mention this as well just in case.
This is the Repro Place: Third Person Test - Roblox
I changed it to wait five seconds first then change the mouse behavior. It works when I play my game from the website, but my concern is that it isn’t working in studio. I don’t want to always open up my game just to test if it works.
Repro Steps:
-
Press the play button in Studio. You’ll see you character spawn in and after 5 seconds it should work
-
Run a Local Server with just one player in studio and you’ll see that it doesn’t work
Thank you and sorry for the inconvenience! Any help and/or feedback is appreciated.
Edit
I just realized that when I test in a local server on studio the MouseBehavior stays Default and I can’t really right click and drag my mouse to move the camera.