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

Why can't my tool find the player's neck? [FIXED]

Asked by 10 years ago

IGNORE THIS QUESTION

Ok so I have a gun, and when the onUnEquipped event fires, it's supposed to connect the neck back to the player's head. But for some strange reason, the script gives me an error that says that the Neck doesn't exist, even though it does. Here's the code:

function onUnEquipped(mouse)
    wait(0.01)
    if Selected then
        Selected = false
        Spread = OriginalSpread
        MainGui:Destroy()
        for _,v in pairs(Connect) do
            v:disconnect()
        end
        for i,v in pairs(IgnoreTable) do
            if i > 2 then
                v:Destroy()
            end
        end
        BG:Destroy()
        Torso.Neck.Part1 = Character.Head --This is the line that keeps breaking
        if Arms then
            local Shoulders = {
                Torso:findFirstChild("Left Shoulder");
                Torso:findFirstChild("Right Shoulder")
            }
            if Shoulders then
                Shoulders[1].Part1 = Arms[1]
                Shoulders[2].Part1 = Arms[2]
                Welds[1]:Destroy()
                Welds[2]:Destroy()
                Welds[3]:Destroy()
            end
        end
        for _,v in pairs(FakeArms) do
            v:Destroy()
        end
        Camera.FieldOfView = 70
        Torso.Parent.Humanoid.WalkSpeed = 16
    end
end

Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnEquipped)

Please help!

Answer this question