Hey guys, I am attempting to make a daily objectives system that randomly loops through a table containing other tables to decide what the daily objective is going to be. I keep receiving this error: “ServerScriptService.Scripts.DailyObjectives:91: invalid argument #2 to ‘random’ (interval is empty)”
Could someone please tell me where I may be going wrong?
Thank you!
local objectivesTable = {
ZombieKillsObjective = {
Objective1 = {
Description = "Kill 75 Zombies",
Type = "ZombieKills",
Amount = 75,
RewardXp = 250,
},
Objective2 = {
Description = "Kill 150 Zombies",
Type = "ZombieKills",
Amount = 150,
RewardXp = 500,
},
Objective3 = {
Description = "Kill 50 Zombies",
Type = "ZombieKills",
Amount = 50,
RewardXp = 150,
},
},
PlayTimeObjective = {
Objective1 = {
Description = "Play for 15 Minutes",
Type = "Time",
Amount = 900,
RewardXp = 100,
},
Objective2 = {
Description = "Play for 30 Minutes",
Type = "Time",
Amount = 1800,
RewardXp = 250,
},
Objective3 = {
Description = "Play for 45 Minutes",
Type = "Time",
Amount = 2700,
RewardXp = 400,
}
},
GameObjectives = {
Objective1 = {
Description = "Survive to Round 10",
Type = "Round",
Amount = 10,
RewardXp = 250,
}
}
}
local DailyTask1Index = math.random(1,#objectivesTable.ZombieKillsObjective) -- This is returning an error
print(DailyTask1Index)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.