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")
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")
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.
1 comment
if not Player.Backpack:GetChildren() then print("empty") end