Unlock Player's Mouse

Hey!

I am wondering why I can’t unlock a player’s mouse.

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter

(^) That’s how I lock it, but how can I unlock it?

Thanks!

1 Like

you can do

UserInputService.MouseBehavior = Enum.MouseBehavior.Default

to unlock it

2 Likes

Thanks for your quick reply. I’ll try it!

1 Like

This didn’t work…

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

This uses UserInputService is it in a local script?

Yes, it does.

(Don’t mind, using up the character limit…)

local uis = game:GetService("UserInputService")
wait(10)
print("yeag")
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
wait(4)
uis.MouseBehavior = Enum.MouseBehavior.Default
print("asdas")

if I do this it works for me

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		uis.MouseBehavior = Enum.MouseBehavior.LockCenter
	elseif input.KeyCode == Enum.KeyCode.Q then
		uis.MouseBehavior = Enum.MouseBehavior.Default
	end
end)

and with this I can toggle it and it still works. I think you cant leave roblox studio playtest for it to work

make sure u also dont have firstpersonlock on

What do you mean? Can you explain?

That didn’t work… I am not sure, but the character still faces the direction… I also can’t see the mouse.

local uis = game:GetService("UserInputService")
uis.MouseBehavior = Enum.MouseBehavior.Default

And if you can’t get that to work, do you think it would be best to just enable shiftlock?

The fact of the matter is it should work. Make sure its in a local script and it doesnt fire instantly when the game starts. IF it still doesnt work use shiftlock but dont give up. Failure isnt falling down its staying down.

Alright! Thanks for your help!

And do you have any good recommendations for a shiftlock script?

StarterPlayer-CameraMode make sure its classic

Hey. I already have that. Ideas?