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

How do I clear a players backpack when the player touched a part?

I'm trying to make a game where players can battle in this classic place but there are also some minigames for players to play. When players enter the minigames, how do I clear their backpack?

1 answer

✓ Accepted answer

I will assume that you know very little Lua, or Roblox Lua to be more precise.

To start off, you need to have something that the player will touch, likely a part. Position the part at the entrance, so that you know the player will touch it, and place a Script (Server Script) as a child in that part with the following code:

local detection = script.Parent -- A part that the player touches
detection.Touched:Connect(function(otherPart)
	for _,v in pairs(game:GetService("Players"):GetChildren()) do
		if otherPart:IsDescendantOf(v.Character) then
			v.Backpack:ClearAllChildren()
		end
	end
end)

Cheers. Accept this if it helped you.

2 comments

0

Thank you so much! I've been having a lot of trouble with how to do this. Cheers!

0

Accept his answer please

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