Hi, newbie question. I have this sample of code that I got from the developer website.
Players = game:GetService("Players") for i, player in pairs(Players:GetPlayers()) do print(player.Name) end
This code works when I paste it in a local script but it doesn't when I paste it in a server side script. I don't get an error, but nothing gets printed. I am wondering why this is, and also what code do I need to use to get all players from a server side script. Thanks
wait(#game.Players:GetChildren() > 0) for i,v in pairs(game.Players:GetChildren()) do print(v.Name) end
this should work
@pastel_joga's answer was good, but
wait(#game.Players:GetChildren() > 0)
will cause the game to halt b/c ur passing a boolean to wait()
which expects a number
for i,v in pairs(game.Players:GetChildren()) do print(v.Name) end
So far, the only thing that has worked is to call this code inside a PlayerAdded event. Didn't know this was the only option?