Bad argument #1 (interval is empty)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Fix the error, and make the script function properly.
  2. What is the issue? Include screenshots/videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Script:

function gamemain()
	_G.Winners = {} --clear/reset table	
	_G.WinnerTimes = {}
	local MapData = require(script.MapDecs)
	
	music.Lobby.SoundId = 'rbxassetid://'..MapData['LobbyAudio'][math.random(1,#MapData['LobbyAudio'])]
	FadeInOutMusic(music.Lobby,music.Winner)
	
	for i = 15, 1, -1 do
		game.ReplicatedStorage.Remotes.Text:FireAllClients('Intermission [ '..i..' ]')
		wait(1)
	end
	
	local Maps = game.ServerStorage.Maps:GetChildren()
	local Map1Chosen = Maps[math.random(#game.ServerStorage.Maps:GetChildren())] -- line giving the error
	local Map2Chosen
	repeat wait() Map2Chosen = Maps[math.random(#game.ServerStorage.Maps:GetChildren())] until Map2Chosen ~= Map1Chosen
	local Map3Chosen
	repeat wait() Map3Chosen = Maps[math.random(#game.ServerStorage.Maps:GetChildren())] until Map3Chosen ~= Map2Chosen and Map3Chosen ~= Map1Chosen
	
	local PlayersVoted = {}
	local Map1 = 0
	local Map2 = 0
	local Map3 = 0
	local VotePads = workspace:WaitForChild('Vote Map')	
	
	local P1 = VotePads:WaitForChild('Vote1'):WaitForChild('Button')
	local P2 = VotePads:WaitForChild('Vote2'):WaitForChild('Button')
	local P3 = VotePads:WaitForChild('Vote3'):WaitForChild('Button')
	
	local V1 = VotePads:WaitForChild('Vote1'):WaitForChild('Map'):WaitForChild('SurfaceGui')
	local V2 = VotePads:WaitForChild('Vote2'):WaitForChild('Map'):WaitForChild('SurfaceGui')
	local V3 = VotePads:WaitForChild('Vote3'):WaitForChild('Map'):WaitForChild('SurfaceGui')
	
	local Diff1 local Diff2	local Diff3
	if MapData[Map1Chosen.Name][2] == 'E' then Diff1 = 'EASY' elseif MapData[Map1Chosen.Name][2] == 'M' then  Diff1 = 'MEDIUM' elseif MapData[Map1Chosen.Name][2] == 'H' then Diff1 = 'HARD' elseif MapData[Map1Chosen.Name][2] == 'EX' then Diff1 = 'EXTREME' end
	if MapData[Map2Chosen.Name][2] == 'E' then Diff2 = 'EASY' elseif MapData[Map2Chosen.Name][2] == 'M' then  Diff2 = 'MEDIUM' elseif MapData[Map2Chosen.Name][2] == 'H' then Diff2 = 'HARD' elseif MapData[Map2Chosen.Name][2] == 'EX' then Diff2 = 'EXTREME' end
	if MapData[Map3Chosen.Name][2] == 'E' then Diff3 = 'EASY' elseif MapData[Map3Chosen.Name][2] == 'M' then  Diff3 = 'MEDIUM' elseif MapData[Map3Chosen.Name][2] == 'H' then Diff3 = 'HARD' elseif MapData[Map3Chosen.Name][2] == 'EX' then Diff3 = 'EXTREME' end
	
	V1:WaitForChild('Votes').Text = '0' V1:WaitForChild('Nam').Text = Map1Chosen.Name V1:WaitForChild('Map').Image = 'rbxassetid://'..MapData[Map1Chosen.Name][1] V1:WaitForChild('Difficulty').Text = Diff1 V1:WaitForChild('Difficulty').TextColor3 = MapData[MapData[Map1Chosen.Name][2]] V1:WaitForChild('Creator').Text = 'built by '..MapData[Map1Chosen.Name][4]
	V2:WaitForChild('Votes').Text = '0' V2:WaitForChild('Nam').Text = Map2Chosen.Name V2:WaitForChild('Map').Image = 'rbxassetid://'..MapData[Map2Chosen.Name][1] V2:WaitForChild('Difficulty').Text = Diff2 V2:WaitForChild('Difficulty').TextColor3 = MapData[MapData[Map2Chosen.Name][2]] V2:WaitForChild('Creator').Text = 'built by '..MapData[Map2Chosen.Name][4]
	V3:WaitForChild('Votes').Text = '0' V3:WaitForChild('Nam').Text = Map3Chosen.Name V3:WaitForChild('Map').Image = 'rbxassetid://'..MapData[Map3Chosen.Name][1] V3:WaitForChild('Difficulty').Text = Diff3 V3:WaitForChild('Difficulty').TextColor3 = MapData[MapData[Map3Chosen.Name][2]] V3:WaitForChild('Creator').Text = 'built by '..MapData[Map3Chosen.Name][4]

Can you be more precise? Which line is the one throwing the error?

math.random don’t accept just 0, as an argument.

math.random(value)

is a sugar syntax of

math.random(1, value)

thus it returns an error as argument 1 cannot be larger than argument 2.
I suspect #game.ServerStorage.Maps:GetChildren() returns 0.
and, btw, you can do #Maps instead of #game.ServerStorage.Maps:GetChildren().
(Repeating until for this isn’t a good idea as random values are unpredictable, thereotically, this could go on forever, I suggest you create an array, of numbers then get the value from the array, then remove that value)

1 Like

Did you even call the function “gamemain”?