I have a module script set-up in ReplicatedStorage
somewhat like this:
local Menu = {
Mains = {
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
};
Drinks = {
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
MenuItemHere = {Name = "eeee", Price = 1.111;};
}
}
return Menu
Iām requiring this module script from a ServerScript
and Iām trying to get the number of items that are in the Menu.Mains
table and Menu.Drinks
table, so I do this:
local Menu = require(ReplicatedStorage.Menu) -- require the module script
function ThisIsAFunction()
local Courses = Menu.Mains
local RandomCourse = Courses[math.random(1 #Courses)] -- error: invalid argument #2 to 'random' (interval is empty)
-- this error is happening because '#Courses' = 0. but how?
print(Courses) -- prints a table just like the module script - perfectly fine
print(#Courses) -- prints '0'
-- how is this printing '0' when there is clearly more than 0 items in the table?
end
Why/How is #Courses
equal to 0
when there is clearly items in the dictionary.