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:

local partA = workspace:WaitForChild("PartA")
local partB = workspace:WaitForChild("PartB")
local weld = Instance.new("Weld") -- create new Weld
-- Remember that where the weld is does not really matter
-- but its good to tidy up everything.
weld.Part0 = partA 
weld.Part1 = partB 
--[[ those settings will hold tight 2 parts together
   but if the size are equal, you will probably want
   a offset between each right? C0 is the offset
   relative to Part0 (partA) and C1 Part1 example:
--]]
weld.C0 = CFrame.new(0, 2, 0) -- 2 studs up
weld.C1 = CFrame.new(0,-2,0) -- 2 studs down
weld.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

local partA = workspace:WaitForChild("PartA")
local partB = workspace:WaitForChild("PartB")
local weld = Instance.new("WeldConstraint")
weld.Part0 = partA 
weld.Part1 = partB 
weld.Enabled = true
weld.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