I wrote this code inside of a module script and im trying to check if the value spriteSheet is a table.
local module = {
objects = {}
}
function module.CreateObject(spriteSheet)
if not typeof(spriteSheet) == "table" then error("argument must be a table") return end
table.insert(module.objects, spriteSheet)
print(module.objects)
return module.objects
end
return module
If that is the issue, one glaring cause that I can see is that you’re doing not typeof(spriteSheet) == table, this is because of operator precedence. == has higher precedence, meaning that your expression is basically being evaluated as if (not typeof(spriteSheet)) == "table", meaning that your basically doing if false == "table".
Rewrite it as if typeof(spriteSheet) ~= "table" ...
or if not (typeof(spriteSheet) == "table") if you want, though it’s easier to make mistakes going that route.