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.
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:
local parent = script.Parent
local torso = parent.Torso
local head = parent.Head
local function weld(part0, part1)
local weld = Instance.new("Weld", part0)
weld.Part0 = part0
weld.Part1 = part1
weld.C0 = part0.CFrame:inverse() * part1.CFrame
return weld
end
weld(torso, head)
What this bit here...
part0.CFrame:inverse() * part1.CFrame
... does is get part1's positional and rotational properties in relation to part0.
I hope this helps. Good luck!
what is the purpose of cframe inverse() * part1.Cframe?
@scottmike0 Put simply, it gets part1's positional and rotational properties in relation to part0.
i just tested this and i end up getting head inside torso
local prev = script.Parent
local parts = script.Parent:GetChildren()
for i = 1,#parts do
if (parts[i].className == "Part") then
if (prev ~= nil)then
local weld = Instance.new("Weld")
weld.Part0 = prev
weld.Part1 = parts[i]
weld.C0 = prev.CFrame:inverse()
weld.C1 = parts[i].CFrame:inverse()
weld.Parent = prev
end
prev = parts[i]
end
end
---this script works for welding
---not quite sure how it works
Does it work?
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I tested this answer, and I end up with a head inside a torso