Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Removing a tool from Backpack and StarterGear?

Okay so in a previous question I learned about StarterGear.

So now I need to remove a Tool from 3 places

  • The player's character
  • The player's backpack (if not equipped)
  • the players StarterGear (so they don't respawn with it)

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)

1 answer

✓ Accepted answer

In this script, you are not sure if the player actually has the items. Therefore, you should do a findFirstChildand 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)

1 comment

0

So this worked better than my last script, its just even though after i touched it and it dissapears, It's not in any of the player's things, yet when I reset I get it back. That's weird

This discussion is preserved as it was. New answers, comments, and votes are closed.