Making part rotate and size to player's mouse position

I’m trying to make a cylinder that comes from the player’s hand stretch to the player’s mouse position. I figured I could use the magnitude between the mouse position and the player’s hand to determine the length of the cylinder, but I don’t have any clue on how I could set the position of the cylinder to be coming from the player’s hand, or how I could have it rotate towards the player’s mouse position.

1 Like

You will set the position to the target position, subtracting half the magnitude. This should give you a cylinder about half the way to the target. Then, make the Z size the magnitude. Now your cylinder is as intended.

To get the mouse position, don’t use Player:GetMouse(). You must also Raycast using WorldRoot using the origin from the player’s hand to the mouse’s position.

Rotating to the player’s mouse is simpler. You can do CFrame.lookAt(part.Position, mouse.Position), but make sure the mouse is being raycasted.

1 Like