I'm trying to make a third-person shooter type game of sorts, and I'm running into a couple of problems. One such problem is that I want to lock the player's cursor to the center of the screen like how it's like in a first person shooter.
I have tried using the LockCenter Enum of MouseBehavior shown in ROBLOX Wiki (code below, but its just the example they gave), but my cursor still moves around freely.
local UserInputService = game:GetService("UserInputService")
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.InputChanged:connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
print("delta is (" .. tostring(inputObject.Delta.x) .. ", " .. tostring(inputObject.Delta.y) .. ")")
end
end)

4 comments
Is this in a LocalScript?
Is this in a LocalScript?
The code appears to only be used to return the position of the mouse; I say this b/c of line 6, of how it uses "Delta.x" & "Delta.y."
Also, you could set the player's CameraMode to "FirstPersonLock," as that'll force the player to have first person, like in FPS games, and the cursor will stay in the middle of the screen; however, to add, I recommend not doing "CameraMode = 'LFP' ," and instead use "Enum.CameraMode.LFP," as that's much better. :)