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

How can you remove all the tools in your backpack by touching a part?

Says it in the title.

So, I want to make a sword fighting arena and I have the giving tool bit covered, but now I don't know how to make a part that will remove all the tools in your backpack when you touch it.

1 answer

✓ Accepted answer

It's pretty easy. Make a Touched event, then remove all objects from the players backpack and tools from the character.

local Part = script.Parent

Part.Touched:Connect(function(hit) --"hit" can be named anything.
	if hit.Parent and hit.Parent:FindFirstChild('Humanoid') then --Checks if it's a player.
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Gets the player
		for i,v in pairs(player.Backpack:GetChildren()) do --Checks backpack
			v:Destroy() --Removes object in Backpack
		end
		for i,v in pairs(player.Character:GetChildren()) do --Checks character
			if v:IsA('Tool') then --Checks if it's a tool
				v:Destroy() --Removes object in character
			end
		end
	end
end)

2 comments

1

Thanks! It worked

0

np!

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