ModuleScript + PlayerAdded event == Not working?

Alright so looping through all the players seems to work however that’s very costly and will cause double calls for the .Chatted event listener for mods.

Are you testing this in studio? Your module may add the event too late for it to get players inside of studio.

Further explanation, players load in studio much faster than in-game.

1 Like

Yes, I am, let me see if there’s a difference in results, one moment.

Edit: This worked, thanks.

What update did you make to your script to get it working? Thanks.

I actually didn’t make a change to the original script, I just ran it in the game itself and not studio, lmao.

It depends what you’re doing. Looping through all players once on the module’s initialisation has a negligible performance cost, since GetPlayers is only constructing a table once. You might be overestimating how much this impacts you.

In addition, this will not result in double calls for the Chatted event. Players that are already in the game will not be caught by PlayerAdded, only by the for loop which attaches the function to them.