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

Tried to make random map system.but an error invalid argument #2 to 'random' (interval is empty)?

Asked by 2 years ago

Server script (in serverscriptservice):


local lobby_Duration = 10 local round_Duration = 10 local maps = game:GetService('ReplicatedStorage'):WaitForChild('Map'):GetChildren() local timerval = game.ReplicatedStorage:WaitForChild("TimerValue") local function RTimer () while wait() do for l = lobby_Duration, 0, -1 do timerval.Value = 'Intermission: '..l wait(1) if l == 0 then local map = maps[math.random(1, #maps)] -- this is the problem timerval.Value = 'Teleporting players to '..map.Name wait(1) map.Parent = workspace local players = game.Players:GetChildren() for i = 1, #players do players[i].Character:MoveTo(Vector3.new(-122.5, 55.5, -41.5)) end wait(1) for g = round_Duration,0, -1 do timerval.Value = 'Round '..g..' seconds left' wait(1) if g == 0 then timerval.Value = 'Round over' wait(2) timerval.Value = 'Teleporting players to lobby' wait(1) for i = 1, #players do players[i].Character:MoveTo(Vector3.new(-122.5, 55.5, 32.5)) end map.Parent = maps wait(1) -- repeat again end end end end end end spawn(RTimer)

1 answer

Log in to vote
0
Answered by 2 years ago

try debugging by printing the "#maps" it might be because the variable maps is nil(the defined location doesn't exist) for now try that out.

Ad

Answer this question