So basically when I try this code, instead of printing out all of the player's names, it prints "Players" a bunch of times. I am pretty sure this is referring to game.Players, since when I try doing #Players, it errors out with "Attempted to find length of instance". Is this supposed to happen/How do I fix this without using alternatives e.g. GetChildren. CODE HERE: ` local players = game:GetService("Players") while true do
print(players) players = game:GetService("Players") wait(0.1)
end `
using while true do on detecting a new player is a no-no instead use a function with an event called playerAdded so when somebody joins the game it will fire the function example of the code:
game.Players.PlayerAdded:Connect(function(player) print("a new player has joined he's name is "..player) end)
You are only getting the service and not an array of the players, services are a bunch of functions.
game:GetService("Players"):GetPlayers()
Get players being the function, it will return an array of all players, so if you planned on doing #players then it will return the length of the array.