function PlayerCount() PlayerCount = game.Players:GetChildren() for PlayerCountLoop = 1, #PlayerCount do leaderstats = (PlayerCount[PlayerCountLoop]:WaitForChild("leaderstats")) print(PlayerCount[PlayerCountLoop].Name .. "'s Stats") print(leaderstats.Attack.Value.. " - Attack") print(leaderstats.Defense.Value.. " - Defense") print(leaderstats.Agility.Value.. " - Agility") print(leaderstats.Energy.Value.. " - Energy") print(leaderstats["Power Level"].Value.. " - Power Level") if #PlayerCount < 2 then print("Wait For Another Player") elseif #PlayerCount > 1 then print("We May Begin!") end end end game.Players.PlayerAdded:connect(PlayerCount)
It is printing 'We May Begin!' twice, once when one player joins. Another time when another player joins. I tested it with my friend.
I'm not sure what you're trying to do here, but connecting this to the PlayerAdded
event is not a good way to go about this.
Try using this loop:
while wait() do if Game.Players.NumPlayers < 2 then print("Not enough players") Game.Players.PlayerAdded:wait() else --run game code end end