So I have a part that when touched, removes a certain tool from the Backpack, Character, and StarterGear

When I touch it, it removes it from everything, but when my character Dies it re-appears in their inventory!

here's the script from the part that you touch

script.Parent.Touched:connect(function(hit)


    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then

 

        local character = hit.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        local Bucket = player.Backpack:findFirstChild("Branch")
        local SG = player.StarterGear:findFirstChild("Branch")
        local equip = character:findFirstChild("Branch")

        if Bucket then
                Bucket:Destroy()
        end

        if equip then
                equip:Destroy()

        end

        if SG then
                SG:Destroy()

        end

 

 
 

    end
 
    
    
end)

2 comments

0

Is this in a LocalScript or a Script?

0

@Discern: It has to be a script, because he said it's in a part.