Okay so in a previous question I learned about StarterGear.
So now I need to remove a Tool from 3 places
I made this script, And I deletes it from the startergear, but nowhere else.
Here's the script
local buttonPressed = false script.Parent.Touched:connect(function(hit) if not buttonPressed then buttonPressed = true 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.Branch local SG = player.StarterGear local equip = character.Branch Bucket:Destroy() equip:Destroy() SG.Branch:Destroy() end wait(10) buttonPressed = false end end)
In this script, you are not sure if the player actually has the items. Therefore, you should do a findFirstChild
and check if each one is there. Check this out:
local buttonPressed = false script.Parent.Touched:connect(function(hit) if not buttonPressed then buttonPressed = true 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 wait(10) buttonPressed = false end end)