local gui = game.StarterGui local serverstorage = game:GetService("ServerStorage") local agentsword = serverstorage:WaitForChild("AgentSword") local assassainsword = serverstorage:WaitForChild("AssassainSword") local bystandersword = serverstorage:WaitForChild("BystanderSword") alive = {} for _, player in pairs(game.Players:GetPlayers()) do table.insert(alive, player) end agent = alive[math.random(1, #alive)] humanoid = agent:WaitForChild("Humanoid") agent:MoveTo(game.Workspace.AgentSpawn.Position)
Error: ServerScriptService.MainScript:14: bad argument #2 to 'random' (interval is empty)
The script runs before there are any players in the server, so #alive will equal 0 and the math.random function will break the script.
Add this before the for loop on line 10:
repeat wait() until game.Players.NumPlayers > 0 --You can change this if you like so that the agent is chosen when a certain number of players enter the game.