I was trying to make a bomb tag game, so I tried to make a random player start with the bomb. But for some reason, I get an error.
local Players = game:GetService("Players"):GetChildren() local Randomplayer = Players[math.random(1, #Players)] print(Randomplayer) EquipBomb:FireClient(Randomplayer, Bomb)
I have no idea what to do, I've looked at many websites and none have helped.
Invalid argument #2 to random is basically an error when the 2nd argument of math.random is less than the 1st argument. Try to add a wait() before the random player thing executes since once you press the play button the script just starts running before the player fully loads in and so #game.Players:GetChildren() is still 0.
wait(4) local players = game.Players:GetChildren() local random = players[math.random(1,#players)] print(random)