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

Why isn't this working with Unions?

Asked by 9 years ago

I found a model that is supposed to make sure my tool doesn't fall out of the players hand. It works with parts only, and I have unions in my tool so I've tweaked it a little but it isn't working, here is the script:

function Weld(x,y)
    local W = Instance.new("Weld")
    W.Part0 = x
    W.Part1 = y
    local CJ = CFrame.new(x.Position)
    local C0 = x.CFrame:inverse()*CJ
    local C1 = y.CFrame:inverse()*CJ
    W.C0 = C0
    W.C1 = C1
    W.Parent = x
end

function Get(A)
    if A:IsA("BasePart") or A:IsA("UnionOperation") then
        Weld(script.Parent.Handle, A)
        A.Anchored = false
    else
        local C = A:GetChildren()
        for i=1, #C do
        Get(C[i])
        end
    end
end

Get(script.Parent)

Answer this question