Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you detect if a players backpack is empty?

Asked by 5 years ago

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")
0
if not Player.Backpack:GetChildren() then print("empty") end whenallthepigsfly 541 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question