Im trying to make this script print the names of all players in the game please help!
for i, v in pairs(game.Players:GetPlayers()) do print(i)---player priority print(v)---players name end
game:GetService("Players").PlayerAdded:Connect(function() for i,v in pairs(game:GetService("Players"):GetPlayers()) do print(v.Name) end end)
when someone joins the game you make a loop through all the players and print their names
Instead of using an in pairs loop, I would print them in a table so it's easier to read. Here
local playerService= game:GetService("Players") local playerTable= { } game.Players.PlayerAdded:Connect(function(player) table.insert(playerTable[player.Name]) end game.Players.PlayerRemoved:Connect(function(player) table.remove(playerTable[player.Name]) end while wait(15) do print("playerTable") end