Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does ServerScriptService.MainScript:56: bad argument #2 to 'random' (interval is empty) mean?

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?????

4 comments

0

I think you reversed it, try local ChosenMap = AvailableMaps[math.random(#AvailableMaps, 1)]

0

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.

0

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)]

0

local AvailableMaps = MapsFolder:GetChildren() local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)] This is the script and MapsFolder is where I store my maps.

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.