Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do You Weld Things to Players Using a Script?

Asked by 5 years ago

I've never done anything like this before and don't really know where to start. For instance, if I wanted a player to have a brick attached to their torso when they click a part, how would I do this? I plan on doing something similar to this (using parts that are uncancollided and weightless, as I simply need the visual aspect). Thanks so much in advance.

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

There are many ways you can weld a part to a player, here are some:

Instance Weld used for holding two parts together in a fixed position relative to each other. EXAMPLE:

01local partA = workspace:WaitForChild("PartA")
02local partB = workspace:WaitForChild("PartB")
03local weld = Instance.new("Weld") -- create new Weld
04-- Remember that where the weld is does not really matter
05-- but its good to tidy up everything.
06weld.Part0 = partA
07weld.Part1 = partB
08--[[ those settings will hold tight 2 parts together
09   but if the size are equal, you will probably want
10   a offset between each right? C0 is the offset
11   relative to Part0 (partA) and C1 Part1 example:
12--]]
13weld.C0 = CFrame.new(0, 2, 0) -- 2 studs up
14weld.C1 = CFrame.new(0,-2,0) -- 2 studs down
15weld.Parent = partA

Now you should have something like this. And that's the basic concept of Weld, sure you can do different offsets, but now, moving to WeldConstraint Weld constraints are used for welding two parts on their last known position, example

1local partA = workspace:WaitForChild("PartA")
2local partB = workspace:WaitForChild("PartB")
3local weld = Instance.new("WeldConstraint")
4weld.Part0 = partA
5weld.Part1 = partB
6weld.Enabled = true
7weld.Parent = partA

And thats the base concept for WeldConstraint, if you are going to use them for a suit for example, you would need to move the part to be welded away from another part and weld as quick as possible for preventing misplacements like 4,000052, I recommend using it only when building something.

Those are only some of the weld types in Roblox, you can find more about them in developer wiki, and thats it really. Hope this helps, good luck on your projects!

1
Thanks so much. corncob567 275 — 5y
Ad

Answer this question