How do you make a drag and weld system?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    how do you make a drag system which also allows you to weld it to other parts, kind of like a dusty trip and dead rails, im not asking for an entire system, but just how they do it.
1 Like

Would be a good start.

to clarify, the dragging isn’t really the big problem, for me its the welding

Couldn’t you just make it so the part is anchored, and un-anchored when a player interacts with it and drags it using the Roblox documentation that @Vos_Despero suggested.

1 Like

i need it to weld so it moves along with the object

Not sure how dusty trip does it, but you could shoot a raycast in the direction of the mouse’s UnitRay, positioning the object at the location of the ray.Position using an AlignPosition instance. Then, when you want to weld the object, the ray.Hit is the target which the object should be welded to.

Use Weld constraints


:wrench: Grab System with Rotation Support

Hi! A few years ago, I worked on a drag-and-drop system similar to the one in Lumber Tycoon 2. It’s also quite similar to Dusty Trip.

I open-sourced the project here:

The two most important scripts are:

  • Client Script:
    game.StarterPlayer.StarterPlayerScripts.LocalScript.Grab
    Handles the grab movement and rotation logic on the client.

  • Server Script:
    game.ServerScriptService.Script.Grab
    Manages network ownership for smooth physics replication.

:magnet: Weld System

  1. For the weld system, I recommend setting up a cubic hitbox around your part. You can use workspace:GetPartBoundsInBox() to detect nearby parts that intersect with the hitbox.

  2. Check if any of the intersecting parts belong to a model the player is allowed to weld with.

  3. If a valid target is found, create a Weld inside the primary part of your grabbed model. To align the two parts correctly, you’ll need to do some basic CFrame math:

local cf0 = CFrame.new()
local cf1 = partToWeld.CFrame:PointToObjectSpace(grabModelPrimaryPart.CFrame) -- to calculate the CFrame offset between the two parts

const weld = Instance.new("Weld")
weld.C0 = cf0
weld.C1 = cf1
weld.Part0 = partToWeld
weld.Part1 = grabModelPrimaryPart
weld.Parent = grabModelPrimaryPart

Hope this helps!

4 Likes

how would you detect if the player presses a key and then weld it, would you use a client script and a remote event,? and how do you detect when the player is currently holding the item