Workspace.Limitations:5: attempt to call local 'AllPlayersInGame' (a table value) when I put v to not make it a table value
local Player = game:GetService("Players") local AllPlayersInGame = Player:GetPlayers() while wait(1) do for i,v in pairs(AllPlayersInGame()) do local thePlayer = tostring(v.Name) print(thePlayer) end end
And you're trying to call it, and it has no __call
metamethod, and will thus error. Simply removing the parenthesis ()
will fix it.
Player
is a misleading identifier for your variable that contains the Players
service. It is not referring to a specific player, but the players service. Also, your table will not update if a player joins or leaves.
Finally, do not use ~~while wait(t) do ... end
~~. This is not a good idiom to follow. It only works because of a hack; a trick.
Use
lua
while (true) do
--// ...
end
It's clearer.
```lua local Players = game:GetService("Players");
while (true) do for _, client in ipairs(Players:GetPlayers()) do print(client); --// no need for tostring end wait(1); end ```