How to make so player can move an object

Hey, so i am trying to achieve a system where there will be arrows around the part and the player will be able to move the part, basically a system like how you move parts in roblox studio, i tried adding surface gui and making a tetx button drgaggable but nothing seems to work, anyone have any suggestions?

Use Handles.

You can read player’s interactions with those handles, when you get the signal that a handle is dragged or clicked, change the CFrame of the part on server, by using a Remote from client

3 Likes

Thanks i managed to code something out of it but like is there anyway to detect what the arrow is looking at, theres the enum.NormalId but like lets say the part rotates and then proceeds to get moved, it would not just work properly, heres the server code

game.ReplicatedStorage.RemoteEvents.Move.OnServerEvent:Connect(function(player, face, distance, part)
	print(distance, face)
	distance = distance / 10
	if face == Enum.NormalId.Top then
		part.CFrame = part.CFrame + Vector3.new(0,distance,0)
	elseif face == Enum.NormalId.Right then
		part.CFrame = part.CFrame + Vector3.new(distance,0,0)
	elseif face == Enum.NormalId.Left then
		part.CFrame = part.CFrame - Vector3.new(distance,0,0)
	elseif face == Enum.NormalId.Front then
		part.CFrame = part.CFrame - Vector3.new(0,0,distance)
	elseif face == Enum.NormalId.Back then
		part.CFrame = part.CFrame + Vector3.new(0,0,distance)
	end
end)

You dont need to add a Vector to the CFrame. Otherwise the movement is relative to the world and not relative to the part CFrame coordinates.

No matter how you do rotate a part, if you change a specific coordinate of the CFrame will make that part go into that direction. So, left is always left relative to the part (not the world):

local part = workspace.Part
part.CFrame *= CFrame.new(0,1,0) -- this will make the part always go facing to the top no matter how you rotate it
-- Same if you change any X,Y,Z

sorry for not formulating well this si the issue im running into
as you can see it work but itll always add the z value to the right arrow and if the part is rotatated, its gonna get wrong

But thats exactly the issue that gets fixed with what I said:

Just for fun I created a script like yours but I used the CFrame suggestion I gave you, and even if I rotate it, it goes perfectly to where it should be

local constantSpeed = 1/10

local facePatterns = {
	[Enum.NormalId.Top] = CFrame.new(0,constantSpeed,0),
	[Enum.NormalId.Bottom] = CFrame.new(0,-constantSpeed,0),
	[Enum.NormalId.Right] = CFrame.new(constantSpeed,0,0),
	[Enum.NormalId.Left] = CFrame.new(-constantSpeed,0,0),
	[Enum.NormalId.Front] = CFrame.new(0,0,-constantSpeed),
	[Enum.NormalId.Back] = CFrame.new(0,0,constantSpeed),
}

game.ReplicatedStorage.RemoteEvents.Move.OnServerEvent:Connect(function(player, face, part)
	part.CFrame *= facePatterns[face]
end)

ohh sorry i put the cframe thing at the top of the remote event, thanks for clarifying it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.