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

Help with tables?

Asked by
AZDev 590 Moderation Voter
8 years ago
Tool = script.Parent;
local arms = nil
local torso = nil
local welds = {}
local model = nil

function Equip(mouse)
    wait(0.01)
    arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
    torso = Tool.Parent:FindFirstChild("Torso")
    if arms ~= nil and torso ~= nil then
        local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
        if sh ~= nil then
            local yes = true
            if yes then
                yes = false
                sh[1].Part1 = nil
                sh[2].Part1 = nil
                local torsoCF = torso.CFrame
                model = Instance.new("Model", workspace)
                local humanoid = Instance.new("Humanoid", model)
                local armcL = Tool.Parent:FindFirstChild("Left Arm"):Clone()
                armcR = Tool.Parent:FindFirstChild("Right Arm"):Clone()
                armcL.CanCollide = false
                armcR.CanCollide = false
                armcL.Parent = model
                armcL.Size = Vector3.new(1, 2.8, 1)
                armcR.Parent = model
                for i,v in pairs (Tool.Parent:GetChildren()) do
                    if v:IsA("Shirt") then
                        local shirt = v:Clone()
                        shirt.Parent = model
                    end
                end
                arms[1].Transparency = 1
                arms[2].Transparency = 1
                local farmLW = Instance.new("Weld", torso)
                farmLW.Part0 = torso
                farmLW.Part1 = armcL
                farmLW.C1 = CFrame.new(-0.4, 0.8, 0.6) * CFrame.fromEulerAnglesXYZ(math.rad(320), 0, math.rad(-90))
                local farmRW = Instance.new("Weld", torso)
                farmRW.Part0 = torso
                farmRW.Part1 = armcR
                farmRW.C1 = CFrame.new(-1, 0.5, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-0), 0)
                weld1 = Instance.new("Weld")
                weld1.Part0 = torso
                weld1.Parent = torso
                weld1.Part1 = arms[1]
                weld1.C1 = CFrame.new(-0.4, 0.5, 0.8) * CFrame.fromEulerAnglesXYZ(math.rad(320), 0, math.rad(-90))
                welds[1] = weld1
                weld2 = Instance.new("Weld")
                weld2.Part0 = torso
                weld2.Parent = torso
                weld2.Part1 = arms[2]
                weld2.C1 = CFrame.new(-1, 0.5, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-0), 0)
                welds[2] = weld2
            end
        else
            print("sh")
        end
    else
        print("arms")
    end
end

----------------------------[v The problem begins here v]-------------------------------

function Unequip(mouse)
    if arms ~= nil and torso ~= nil then
        local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
        if sh ~= nil then
            local yes = true
            if yes then
                yes = false
                sh[1].Part1 = arms[1] -- This works
                sh[2].Part1 = arms[2] -- This works
                welds[1] = nil -- This is just one of my many attempts to fix this.
                welds[2] = nil --  Same here
                model:Destroy() -- not working
                arms[1].Transparency = 0 --This works
                arms[2].Transparency = 0 -- This works
            end
        else
            print("sh")
        end
    else
        print("arms")
    end
end
Tool.Equipped:connect(Equip)
Tool.Unequipped:connect(Unequip)

I am not exactly sure what is wrong here. Everything was working just fine. I hadn't made any changes to it until after.

I can't set the welds to nil and I can't call the :Destroy() method on model. There are no errors. It just doesn't work.

Any help would be appreciated since I have been trying to figure this out for two days now.

2
A comment since u didn't get one all day koolkid8099 705 — 8y
0
Upvoted cuz heck why not. I still need an answer though. AZDev 590 — 8y
0
I edited the question to provide more about what is happening . AZDev 590 — 8y

Answer this question