I simply just want to print the names of the players in the server, though my script doesn't work (it doesnt show any errors though), it is a ServerScript placed in workspace
local getPlayers = game.Players:GetPlayers() for i, v in pairs(getPlayers) do print(i.." = "..v.Name) end
this will ensure the script runs if theres a player
local Players = game:GetService("Players"):GetPlayers() repeat task.wait() Players = game:GetService("Players"):GetPlayers() until Players[1] for i,v in pairs(Players) do print(i,v) end
The in pairs loop probably executed before a single player even connected, so all we have to do is put a wait(). Something like this.
wait(1) local getPlayers = game.Players:GetPlayers() for i, v in pairs(getPlayers) do print(i.." = "..v.Name) end