I was making a game and I came across this error ServerScriptService.MainScript:56: bad argument #2 to 'random' (interval is empty). The script line: local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)] Can someone help me?????
✓ ANSWER ACCEPTED
What does ServerScriptService.MainScript:56: bad argument #2 to 'random' (interval is empty) mean?
1 answer
✓ Accepted answer
"Interval is empty" reffers to the #AvalibleMaps part. That means this number is returning as 0 or nil. Double check you dont have a silly mistake such as calling :GetChildren() on a table or you miscounted .Parent's or something along those lines. If none of that works, send the code and I will help you out.
3 comments
0
Thanks I didn't have the map in the folder. I was fixing a bug for the spawn points in work space and forgot to put it back into the folder
0
it works thx
0
NP!
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
I think you reversed it, try local ChosenMap = AvailableMaps[math.random(#AvailableMaps, 1)]
How is AvailableMaps set up? Is it a standard table or do you have a GetChildren set to it? Can you please release more of the script so that we may help you.
There is a folder with my maps in it called MapsFolder that I created a variable for. here's the script for AvailableMaps local AvailableMaps = MapsFolder:GetChildren() local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
local AvailableMaps = MapsFolder:GetChildren() local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)] This is the script and MapsFolder is where I store my maps.