How to use handle adornments to move parts

Hello,

I’m curious as to how you move parts using the handle adornments. I’ve searched the developer forums for an answer or some guidance but I could not find anything relating to it. The developer api-reference does not have much information either.
DevAPI Reference: https://developer.roblox.com/api-reference/class/Handles
image
image

Thank you in advance.

3 Likes

Use the events found in the api page to determine if the handle was grabbed then get the player’s mouse position to move the part

3 Likes

I’ve tried this code but when I drag it back and forth it moves really weirdly.

script.Parent.MouseDrag:Connect(function(Face, Distance)
 workspace.Part.Position = workspace.Part.Position + Vector3.new(Distance)
end)

You’re gonna have to adjust it based on the face you are dragging. The Face property returns a NormalId and based on that you can set the position. Here’s an example

-- If the top face is being dragged then apply the distance vertically
if Face == Enum.NormalId.Top then
   workspace.Part.Position = workspace.Part.Position + Vector3.new(0, Distance, 0)

-- Otherwise if the bottom face is being dragged, apply negative distance vertically
elseif Face == Enum.NormalId.Bottom then
  workspace.Part.Position = workspace.Part.Position + Vector3.new(0, -Distance, 0)
end

Do the same for all the other faces.

5 Likes
local PartToMove = put part here
local movetool = put handles
	local origin = PartToMove.CFrame
	movetool.MouseDrag:Connect(function(a, b)
		if a.Value == 5 then
			PartToMove.CFrame = origin + PartToMove.CFrame.LookVector * b
		elseif a.Value == 2 then
			PartToMove.CFrame = origin + PartToMove.CFrame.LookVector * -b
		elseif a.Value == 1 then
			PartToMove.CFrame = origin + PartToMove.CFrame.UpVector * b
		elseif a.Value == 4 then
			PartToMove.CFrame = origin + PartToMove.CFrame.UpVector * -b
		elseif a.Value == 0 then
			PartToMove.CFrame = origin + PartToMove.CFrame.RightVector * b
		elseif a.Value == 3 then
			PartToMove.CFrame = origin + PartToMove.CFrame.RightVector * -b
		end
	end)
	movetool.MouseButton1Up:Connect(function()
		origin = PartToMove.CFrame
	end)

Yes I know that this post was 3 years old.

11 Likes

This is how it’s done if you want to use it with a grid ;D

wait(2)
local GridSize = game:GetService("ReplicatedStorage"):WaitForChild("GridSize")

local PartToMove = workspace.Part
local movetool = PartToMove.Handles
local origin = PartToMove.CFrame
PartToMove.Handles.Parent = game:GetService("Players").LocalPlayer.PlayerGui

movetool.MouseDrag:Connect(function(a, b)
	if a.Value == 5 then
		PartToMove.CFrame = origin + PartToMove.CFrame.LookVector * math.round(b/GridSize.Value)*GridSize.Value
	elseif a.Value == 2 then
		PartToMove.CFrame = origin + PartToMove.CFrame.LookVector * -math.round(b/GridSize.Value)*GridSize.Value
	elseif a.Value == 1 then
		PartToMove.CFrame = origin + PartToMove.CFrame.UpVector * math.round(b/GridSize.Value)*GridSize.Value
	elseif a.Value == 4 then
		PartToMove.CFrame = origin + PartToMove.CFrame.UpVector * -math.round(b/GridSize.Value)*GridSize.Value
	elseif a.Value == 0 then
		PartToMove.CFrame = origin + PartToMove.CFrame.RightVector * math.round(b/GridSize.Value)*GridSize.Value
	elseif a.Value == 3 then
		PartToMove.CFrame = origin + PartToMove.CFrame.RightVector * -math.round(b/GridSize.Value)*GridSize.Value
	end
end)

movetool.MouseButton1Up:Connect(function()
	origin = PartToMove.CFrame
end)