Hey all. Lately iv’e been trying to make a classic styled dragging/move system for parts, i have the basics done, but now i have issues to solve. And that is when dragging the part, its orientation and position does not affect it when placed on a moved/rotated object. And parts cannot be placed on the side of other parts. Some help will be much appreciated!
Functions from LocalScript
Mouse.Button1Down:Connect(function()
if Mode.Value == 1 and Equipped == true then
if Mouse.Target ~= nil then
if Mouse.Target.Locked == false then
SlashAnim()
if Mouse.Target.Parent.ClassName == "Model" and Mouse.Target.Locked == false then
else
if Mouse.Target:IsA("BasePart") then
if Dragging == false then
Dragging = true
local Part = Mouse.Target
ObjBeingDragged = Part
ObjBeingDragged:BreakJoints()
StartMoveObjectEvent:FireServer(ObjBeingDragged)
ObjBeingDragged.Parent = Tool
local Increment = 1
local function filter(number,increment)
number = math.floor(number)
number = number-(number%increment)
return number
end
while Dragging == true do
wait()
if ObjBeingDragged ~= nil and Mouse.Target ~= nil and Mouse.Target ~= ObjBeingDragged then
Part.Anchored = true
ObjBeingDragged.CanCollide = false
Part.CFrame = CFrame.new(filter(Mouse.Hit.X,Increment),Mouse.Hit.Y + (Part.Size.Y/2),filter(Mouse.Hit.Z,Increment))
end
end
end
end
end
end
end
end
end)
function ReleaseObj()
if ObjBeingDragged ~= nil then
EndMoveObjectEvent:FireServer(ObjBeingDragged, ObjBeingDragged.Position, Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)
ObjBeingDragged.Parent = game.Workspace
ObjBeingDragged.CanCollide = true
ObjBeingDragged = nil
Dragging = false
end
end
Functions from ServerScript
EndMoveEvent.OnServerEvent:Connect(function(player, Object, Pos, mouseX, mouseY, mouseZ)
MouseX = mouseX
MouseY = mouseY
MouseZ = mouseZ
if Object.Parent.ClassName == "Model" then
else
if Object:IsA("BasePart") then
Object.CanCollide = true
Object.Anchored = false
Object.Parent = game.Workspace
Object:BreakJoints()
local Increment = 1
local function filter(number,increment)
number = math.floor(number)
number = number-(number%increment)
return number
end
Object.CFrame = CFrame.new(filter(MouseX,Increment),MouseY + (Object.Size.Y/2),filter(MouseZ,Increment))
Object:MakeJoints()
end
end
end)
StartMoveEvent.OnServerEvent:Connect(function(player, Object, Pos)
if Object.Parent.ClassName == "Model" then
else
if Object:IsA("BasePart") then
Object.CanCollide = false
Object.Anchored = true
end
end
end)
So for orientation problem. I am thinking about doing this. For the part that is draggable.
local Part = script.Parent
Part.Touched:Connect(function(Hit)
if Hit ~= nil then
if Hit.Parent and Hit:IsA("BasePart") then
if game.Players:FindFirstChild(Hit.Parent.Name) then
else
Part.Orientation = Hit.Orientation
end
end
end
end)
This may fix it, since when part touches something, it sets same orientation as the part that it touched
This is perfect. It is nice and easy to understand, not to difficult to get working with my tool system, and has all the required things that i needed. Thanks man!
all though, there is one issue. when i release my mouse button to place the part, it doesn’t attach to any surfaces. How would i fix this? iv’e even tried using the :MakeJoints() function, and not even that will work.
Your scale tool welds parts being scaled to what ever they are touching, but the drag and copy tool doesn’t have that weld / join surface feature.
Does your part have a surface that can attach to the other part’s surface? It will only weld if that’s the case. Last time I used the tools which wasn’t recently they worked fine, but Roblox have made some changes to surface joints recently which may be the reason why it’s no longer working. I’ll have a look at it when I get home.
Yeah, even when i try to attach a part with studs, to a part with inlets, or even a weld surface, it will not work. Its like ever so slightly off centered or rotated when i drag it.
So it seems like an update has changed a few things. Firstly, any surface type now join to any other surface type and welds successfully, so a smooth surface will weld to any other surface including another smooth surface. Secondly, the copy tool no longer automatically welds the copied part, you have to move it a bit in order for it to weld.
As for your issue of nothing attaching at all, I’m not sure what could be causing that issue.
This looks related to the recent changes to surface weld tools in studio (which also changed the behavior of Workspace:JoinToOutsiders if you’re using that).
Read that post and see if the behavior matches what you’re seeing.
My god, i have figured out why it wasnt joining surfaces. You have to enable the JoinSurfaces option in studio in the top bar > home > JoinSurfaces. I thought this would only affect building while in studio, not testing or playing the place.
Very strange move for ROBLOX to be totally honest. What if you wan’t to build in roblox studio with joining surfaces off. But have joining surfaces on in-game? Very weird if you ask me
This actually looks like a bug with when running studio in Play mode. MakeJoints should always work, regardless of the JoinSurfaces setting.
MakeJoints should still be functioning properly in a published live game, but it looks like if you enter Play mode while Join Surfaces is off, MakeJoints does nothing. I’ll get to fixing this soon after the holiday break.