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?
✓ ANSWER ACCEPTED
How do I clear a players backpack when the player touched a part?
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thank you so much! I've been having a lot of trouble with how to do this. Cheers!
Accept his answer please