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

humanoid weld script not working correctly?

Asked by
0msh 333 Moderation Voter
4 years ago

this script is supposed to weld all the children inside the model, which it does weld. But the problem is, sometime it welds weird, such as welding the left leg to the head or welding a part inside of the model where it supposed to be it welds it somewhere else. If you have other ways to approach this, please share

local prev 
local parts = script.Parent:GetChildren() 

for i = 1,#parts do 
    if (parts[i].className == "Part") or (parts[i].className == "WedgePart") or (parts[i].className == "UnionOperation") or (parts[i].className == "MeshPart") or (parts[i].className == "CornerWedgePart") 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]
        parts[i].Anchored = false
    end
end
0
:GetChildren( ) will return a table of children in random order. This explain why your script act weird. I don't have any solution right now, but hope it help you solve your problem. Block_manvn 395 — 4y
0
how can I fix that? 0msh 333 — 4y

Answer this question