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

InstaWeld with Unions?

Asked by 10 years ago

How can I make this work for Unions so not only parts will be welded?

local prev 
local parts = script.Parent:GetChildren() 
for i = 1,#parts do 
    if (parts[i].className == "Part") then 
        if parts[i].Name ~= "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 
end
for i = 1,#parts do 
    if (parts[i].className == "Part") then 
        if parts[i].Name == "Left Leg" or parts[i].Name == "Right Leg" then
            parts[i].CanCollide = true
        end
        if parts[i].Name ~= "Part" then
                parts[i].Anchored = false 
                end
    end
end

1 answer

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

In order to get this to work, you just need to check if the parts are BaseParts or UnionOperations (The ClassName for Unions).

The following would replace lines 4 and 19 in your code block:

if (parts[i].ClassName == "BasePart") or (parts[i].ClassName == "UnionOperation") then
0
Still not working Opptitronica 0 — 10y
0
Does it weld normal parts? BlackJPI 2658 — 10y
Ad

Answer this question