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 8 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 — 8y

2 answers

Log in to vote
0
Answered by 8 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:

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!

0
what is the purpose of cframe inverse() * part1.Cframe? scottmike0 40 — 8y
0
@scottmike0 Put simply, it gets part1's positional and rotational properties in relation to part0. Programmix 285 — 8y
0
i just tested this and i end up getting head inside torso scottmike0 40 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
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 
0
Does it work? Programmix 285 — 8y

Answer this question