#Why does a table return nil in a module script
10 messages · Page 1 of 1 (latest)
if you print out #rooms then it will be 0
Yes
because you are using a key-based system (e.g. 'TopMiddle' and 'TopLeft' are keys)
it's not a numerical array where you can just do rooms[math.random(#rooms)]
well i would utilize a for loop and assign each key into a table, where you can pick randomly from that table
example
local crazyThing = {
Chicken = {},
Dog = {},
Cat = {},
Dragon = {},
Mouse = {},
}
local selections = {}
for key,_ in pairs(crazyThing) do
table.insert(selections, key)
end
print(selections[math.random(#selections)])
Oh okay