Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

0
I think you reversed it, try local ChosenMap = AvailableMaps[math.random(#AvailableMaps, 1)] Igoralexeymarengobr 365 — 5y
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. M39a9am3R 3210 — 5y
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)] tyorange09 4 — 5y
0
local AvailableMaps = MapsFolder:GetChildren() local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)] This is the script and MapsFolder is where I store my maps. tyorange09 4 — 5y

1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
5 years ago

"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.

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 tyorange09 4 — 5y
0
it works thx tyorange09 4 — 5y
0
NP! mc3334 649 — 5y
Ad

Answer this question