You are basically asking for how to make the part follow the mouse.
-
The Player’s Mouse object has a property called
Hit
, which is essentially the position. of the mouse in 3D space -
Every frame, if an object is being placed, you can update the CFrame of the object to Mouse.Hit, which will move it to the mouse’s location in 3D space.
-
If you want the initial rotation of the part to be preserved, you’ll have to construct a CFrame that has the same rotation as the object’s initial CFrame, but a different position when you move it to the mouse.
There is a guide on the devforum about a similar system, but it’s a bit more complex than your use case. However, it will be helpful when you want to implement features like collision checking, so the player can’t overlap multiple parts, or saving the parts placed. It’s worth looking at, if not there have been a multitude of guides published on this sort of system.
This requires some knowledge of how CFrame works, and binding all of the logic to RenderStepped or Heartbeat.