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

How to check if a table is empty?

function empty()
	print("table empty")
end
-- Place i need help with --

3 answers

✓ Accepted answer

Using #Table will give you the length of it.


table = {182}

function is_empty(x)
if #table<=0 then
return true
end
end

`

if #table < 1 then
	print("Table is empty.")
end

Hope that helped^

You can do a few things.

local t = {}

if #t < 1 then
 --do code
end

if not t[1] then
 --do code
end

for i,v in pairs(t) do
  if not v then
    --do code
    end
end

1 comment

0

loooooool

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