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.
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:
01 | local parent = script.Parent |
02 | local torso = parent.Torso |
03 | local head = parent.Head |
04 |
05 | local function weld(part 0 , part 1 ) |
06 | local weld = Instance.new( "Weld" , part 0 ) |
07 | weld.Part 0 = part 0 |
08 | weld.Part 1 = part 1 |
09 |
10 | weld.C 0 = part 0. CFrame:inverse() * part 1. CFrame |
11 |
12 | return weld |
13 | end |
14 |
15 | weld(torso, head) |
What this bit here...
1 | part 0. CFrame:inverse() * part 1. CFrame |
... does is get part1's positional and rotational properties in relation to part0.
I hope this helps. Good luck!
01 | local prev = script.Parent |
02 | local parts = script.Parent:GetChildren() |
03 | for i = 1 ,#parts do |
04 | if (parts [ i ] .className = = "Part" ) then |
05 | if (prev ~ = nil ) then |
06 | local weld = Instance.new( "Weld" ) |
07 | weld.Part 0 = prev |
08 | weld.Part 1 = parts [ i ] |
09 | weld.C 0 = prev.CFrame:inverse() |
10 | weld.C 1 = parts [ i ] .CFrame:inverse() |
11 | weld.Parent = prev |
12 | end |
13 | prev = parts [ i ] |
14 | end |
15 | end |
16 | ---this script works for welding |
17 | ---not quite sure how it works |