LockCenter not working

Hello, I’m having trouble locking the mouse of the player. I’ve seen other people having the same problem. This the piece of code I’m using:

RunService:BindToRenderStep("SetCamera", Enum.RenderPriority.Camera.Value, function()
	UIS.MouseBehavior = Enum.MouseBehavior.LockCenter;

No errors. Tried forking the BaseCamera module from roblox, didn’t get any results either. I have no other piece of code in my entire place messing with UIS.MouseBehavior, so I don’t know what’s causing this issue and how can I fix.

  1. Subtract one from the Enum.RenderPriority.Camera.Value.
  2. That MouseBehavior will not actually lock the mouse. You need to use LockCurrentPosition.

Forgot to mention that LockCenter seems to work on other place. This may make you think it has something to do with code on my place, but as I said I don’t have anything that messes with the MouseBehavior.

Do I lock it after doing LockCenter every frame?

RunService:BindToRenderStep("SetCamera", Enum.RenderPriority.Camera.Value -1, function()
	UIS.MouseBehavior = Enum.MouseBehavior.LockCenter;
	UIS.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition

Tried this, didn’t work either.

You could be using the mouse locking system against the protected use cases.
Roblox prevents locking the mouse in some situations, to protect users against Robux scams.

How would I counter it? There isn’t really any work-around for this and I really need this to work for my combat system.

And why does it only happen to me?

You cannot counter protected systems, such as those to prevent Robux scams.
If you have the intentions of developing a game that will be a Robux scam, there is no point in me discussing any further with you.
If you don’t have the intentions of doing so, then provide the games use case for this method.

It’s a combat system, I need it to shiftlock.

And again, I have no idea why this issue doesn’t happen in other places.

Set the Camera type in the StarterPlayer instead.

1 Like

I don’t really know what you mean

I just noticed that the roblox default shiftlock also doesn’t lock the mouse.

Ok, turns out it was all because of this piece of code:

Player.PlayerGui.Chat.Frame.Size = UDim2.fromScale(1,1)
Player.PlayerGui.Chat.Frame.ChatBarParentFrame.Size = UDim2.new(.4,0,0,42)
Player.PlayerGui.Chat.Frame.ChatBarParentFrame.AnchorPoint = Vector2.new(1,0)
Player.PlayerGui.Chat.Frame.ChatBarParentFrame.Position = UDim2.new(1,0,0,0)

Don’t ask me why it does that, it must be a bug.

1 Like