I have this script that basically has a table with user id's for y'know, admins. the table is empty with no values so when I try to execute any code with it, it glitches and returns the wrong value, ex: true instead of false. Is there a way to check if a table has any values in it?
✓ ANSWER ACCEPTED
How to check if a table has any values in it?
1 answer
✓ Accepted answer
To check if a table has a key value pair, we can simply use the next() function, like so:
local EmptyTable = {}
if next(EmptyTable) then
print("There's a key-value pair!")
else
print("There's not a key-value pair!")
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
