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

Welding parts to make Character model?

Asked by 9 years ago

I am confused on how to weld characters Lets say I have a torso and Head I want to wield both parts local parent = script.parent local torso = torso local head = head function weld() torso.Part0 head.Part1

?? I am very confused.

0
I tested this answer, and I end up with a head inside a torso scottmike0 40 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

For further posts, you should put code in a code block.

Here's the solution to your problem, assuming the script is in a character:

01local parent = script.Parent
02local torso = parent.Torso
03local head = parent.Head
04 
05local function weld(part0, part1)
06    local weld = Instance.new("Weld", part0)
07    weld.Part0 = part0
08    weld.Part1 = part1
09 
10    weld.C0 = part0.CFrame:inverse() * part1.CFrame
11 
12    return weld
13end
14 
15weld(torso, head)

What this bit here...

1part0.CFrame:inverse() * part1.CFrame

... does is get part1's positional and rotational properties in relation to part0.

I hope this helps. Good luck!

0
what is the purpose of cframe inverse() * part1.Cframe? scottmike0 40 — 9y
0
@scottmike0 Put simply, it gets part1's positional and rotational properties in relation to part0. Programmix 285 — 9y
0
i just tested this and i end up getting head inside torso scottmike0 40 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
01local prev = script.Parent
02local parts = script.Parent:GetChildren()
03for i = 1,#parts do
04if (parts[i].className == "Part") then
05if (prev ~= nil)then
06local weld = Instance.new("Weld")
07weld.Part0 = prev
08weld.Part1 = parts[i]
09weld.C0 = prev.CFrame:inverse()
10weld.C1 = parts[i].CFrame:inverse()
11weld.Parent = prev
12end
13prev = parts[i]
14end
15end 
16---this script works for welding
17---not quite sure how it works
0
Does it work? Programmix 285 — 9y

Answer this question