here's the local script:

local userInputService = game:GetService("UserInputService")

game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed) -- switches between default and lockcenter mouse behaviour
	if input.KeyCode.Name == "BackSlash" then
		if userInputService.MouseBehavior == 0 then
			print ("locking cursor")
			userInputService.MouseBehavior = 1
		else
			print("unlocking cursor")
			userInputService.MouseBehaviour = 0
		end
	end
end)

and i get

unlocking cursor - Client - unlockCursor:9

MouseBehaviour is not a valid member of UserInputService "Instance" - Client - unlockCursor:10

as the output every time i press backslash

4 comments

0

i think using Enum.MouseBehavior will help, for example: Enum.MouseBehavior.LockCenter

0

that's what i tried at first, it had the same result

0

i read the dev wiki, i believe you did it wrong. the value "0" does not exist.

0

if you wanna set it to default, make the value to "1". if lock, make the value to "2"