UserInputService.MouseBehaviour not working?

I have actually tried it out but for me…

This does not work:-

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

But this does:-

local userinputservice = game:GetService("UserInputService")

game:GetService("RunService").Heartbeat:Connect(function(dt)
    userinputservice.MouseBehavior = Enum.MouseBehavior.LockCenter 
end)
2 Likes

Didn’t work. Hmmm… :slightly_smiling_face:

So it isn’t just me!

However, this did work. We have made history, ladies and gentlemen.

Thanks so much!

1 Like

I used “UserInputService.MouseBehavior = 1” and it worked for me, Idk why. There’s a table here for the different number codes: MouseBehavior | Roblox Creator Documentation

Sorry for my lack of formality, new to dev form and am kinda rushing now.

1 Like

Hello, it doesn’t work for me :frowning: is there another way?

I struggled with this problem for a while. I managed to solve it, however, by setting the workspace camera to Camera.CameraType Fixed (it does appear to be working with Custom as well though), and in Starterplayer setting the CameraMode to LockFirstPerson.

This did not work at first, untill I removed all my code that modified UserInputService.MouseBehaviour and player.CameraMode. So removing all the code
that modified it solved my problem.

To be able to move the mouse freely at times, I use a textButton in a ScreenGui with its property Modal set to true.

Hope this helps!