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

Can you detect if a players backpack is empty?

Is there a way to check if the players backpack is empty? I have tried this, bit it didn't work.

for i,v in pairs(Player.Backpack:GetChildren()) do
 v:Destroy()
  if v == nil then
   print("Empty")

1 comment

0

if not Player.Backpack:GetChildren() then print("empty") end

1 answer

✓ Accepted answer

Yes, one method is that most objects contain a function named ":FindFirstChildWhichIsA" which that object tries to find a specific child or descendant with that particular classname.

local BackPack = player.Backpack
if BackPack:FindFirstChildWhichIsA("Tool")==nil then
 print("Backpack does not contain a child that is a tool.")
end

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