Hello, I am trying to do make a good game but why is my Choosing Random Player script is wrong?
Script:
local randomPlayer = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())]
Output:
20:09:07.220 - ServerScriptService.Core.GameScript:12: bad argument #2 to 'random' (interval is empty)
Your problem is that the amount of players in the server is 0
repeat wait() until #game.Players:GetChildren() >= 1 local randomPlayer = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())]
Unsure, but I've seen such scripts be like:
local randomPlayer = game.Players:GetChildren()[math.random(2, #game.Players:GetChildren())]
Notice how I replaced 1 with 2 !