How To Make A Part That A Player Can Drag and Rotate

What are the recommended techniques to enable a player to move or rotate a part?
An example of this is any game that enables the user to move and rotate furniture in their house. Typically the player clicks on the furniture, and then some GUI overlay is shown on the furniture explaining they need to drag to move or rotate the part.

2 Likes

i just scripted this for my game, i use i billboard gui(with a image button) along with some of the functions from the UserInputService, such as TouchMoved , and the Moved event from the mouse class, and for rotating the part on mobile devices i make a button visible (another image button in a billboard gui) to rotate the part while on computer devices i used the ContextActionService:BindAction() function to bind function to rotate the model when the r key is pressed.

1 Like

There are other posts discussing how to make a “part follow mouse”.

Here’s one
And another

If you follow along with those and get the PrimaryPart of your furniture model to follow the mouse, you’re well on your way.

Similarly, if you have a function that rotates your furniture model containing a line like:

model.CFrame = model.CFrame * CFrame.Angles(0, math.pi/2, 0) -- rotate 90 degrees around Y-axis

then you can connect the MouseButton1Down event, for example, to a handler function that checks whether or not the furniture model was clicked on, whether or not it should be turned, how much it should turn, and how/when to call the model rotate function.

But that’s all just a rough idea of how to get started.

You can also clone the model to show a transparent CanCollide = false placeholder model that follows the mouse cursor and the rotation input.

1 Like
2 Likes