How to make mouse stuck at target?

Hello, I am making a sword system for my game. I was wondering how can i make the mouse of player to stuck in some target for example part in workspace and player to be unable to move it. I wanna make a targeting system so when player clicks z the mouse stucks into some other player and the player’s character starts following the mouse like in this game https://www.roblox.com/games/850917308/Star-Wars-Lightsaber-Battles-II?refPageId=58c2a6a7-3079-488e-91ab-7aa5a38057a2

Does anyone know how is that possible? At first i tough i have to use camera manipulation but im not sure now.

1 Like

Hi you can use FindNearestPlayer and then still code do mouse.Position = Target.Head.Position
this is be only example
Tell me if its work Thank you

1 Like

@vojta1587 The Mouse doesn’t have a Position property. Even if it did, you wouldn’t be able to write to it (make a request to change it), like the Mouse’s X, Y and Hit property.

The only solution would be to force the player into first person, or lock the mouse in the center using UserInputService.MouseBehaviour and manipulate the camera’s cframe and the Character to face the target

3 Likes

if wanted to, you can somewhat replicate the effect that the mouse is locked at any position by making a fake mouse and set that mouse to the position you want it to then hide the real mouse and lock it to the center. If you were wondering you cant set the mouse position due to security reasons

3 Likes