How i can make player mouse lock in the middle of screen

i create a simple script for this thing but dont work, can you help me?

wait()

local UserInputService = game:GetService("UserInputService")

UserInputService.MouseIconEnabled = false
UserInputService.MouseBehavior.EnumType(Enum.MouseBehavior.LockCenter)
1 Like

shouldn’t it be

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
6 Likes