Why is this Players service not working

To be honest am so close to breaking my PC right now,

I have spent the last 2 hours trying to make this work but it’s not so,
The problem am having is that I have a while loop and in that while loop is a for loop that loops for every player in the server and prints their name however, it’s only printing 1 of the players names and when that player leaves it starts printing the next player!

while wait() do
     for _, v in pairs(game:GetService("Players"):GetChildren()) do
           print(v.Name) -- only prints one player name
     end
end

Please help me with this as I really need support on this

1 Like

is this the entire script, where is the script parented? What type of script is it? More details would be nice!

So sorry it’s a Module script function

ok, what script is requiring it? and can I see the full code of the module?

Another module script is requiring this module script

ok what script is requiring that one? If its another module script, what script (NOT MODULE) is requiring the modules thats requiring this module
Also please answer my other questions

The script that is requiring the module that is requiring this module is in ServerScriptService and it’s fires the function when it receives the RemoteFunction

what is the full code of the module? What RemoteEvent? Please show all of the code

Am away from my PC right now like out the house so I cant

1 Like

Well when you can, feel free to send in the code so I can have a look at it!
Take your time though!

Looks fine to me. I tried it in a server script and it runs as expected. Seems like you’re doing something odd when calling this.

You probably have some break condition in there.

while wait() do
     for _, v in pairs(game:GetService("Players"):GetChildren()) do
           print(v.Name) -- only prints one player name

           -- stuff idk ...
  
           break -- the problem
     end
end
2 Likes

Thank you so much, yo cant believe I was that stupid :joy:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.