Hello, I was wondering if you could help me with this. I am trying to make a round system based game and I need to keep track of all the players in the server. I decided to use GetPlayers to see who is still in the game when they are leave or join, but another problem is that if I want the person to be removed from the list for some reason (like going AFK). This is a problem since when I use GetPlayers it wont print in the output which leads me to think I cannot assign it's values to another table to later manipulate that.

activePlayers = {}

game.Players.PlayerAdded:Connect(function(player)
	activePlayers = game.Players:GetPlayers()
	print("playeradded")
end)

game.Players.PlayerRemoving:Connect(function(player)
	activePlayers = game.Players:GetPlayers()
	print("playerremoved")
end)



for i,v in pairs(activePlayers) do
	wait(2)
	print(i,v)
end

Sorry if this was a bit confusing. Thank you.

3 comments

0

it will print its just there is no data in the table to print as it runs before a player joins.

0

Yeah but when I play solo it does not ever print.

0

the player is added BEFORE any scripts run in play solo.