So I'm trying to apply/test my beginner knowledge and I appear to have gotten stuck. What I'm trying to explore is the game.Players:GetPlayers() method/function.
I'm guessing that if I call that function after a player is leaving, it will return a table without the player that left? I'm assuming I'm wrong because it doesn't seem to be working. If that's the case, then I'd like some help on how to do exactly that.
Furthermore, an error prompts when the PlayerRemoving event is called, simply saying "An error has occurred" and doesn't print the table.
playerservice = game:GetService("Players")
function print_table(tab) -- I want to print out what's in the table
for i,v in ipairs(tab) do
local val = tostring(v)
print("i = "..i.." v= "..val)
end
end
playerservice.PlayerAdded:connect(function(plr)
print_table(playerservice:GetPlayers())
end)
playerservice.PlayerRemoving:connect(function(plr)
print_table(playerservice:GetPlayers())
end)

2 comments
Ah, many thanks! Thank you for explaining it.
No problem mate. Happy scripting!