I’ve been having this issue with an admin I have been working on the past 3 days, and I’ve ran into an obstacle I can’t seem to get over.
The Issue
When playing in studio, the module script is able to successfully move everything into it’s place, as well as set the script correctly in time for when the Players.PlayerAdded event is fired.
However, when attempting to run the same script, same modules, same everything, but IN-GAME, it seems to be too slow to beat the Players.PlayerAdded. It still moves and does everything it’s supposed to, but when it’s supposed to check for the Player.Chatted, it become unable to detect the chat.
Furthermore, something even more odd, is that even when using Players.PlayerAdded, it’s able to do the first few lines after the event call, and runs properly. One of the lines: Player["PlayerGui"]:WaitForChild("Essentials Admin");, doesn’t nil or yield infinitely, and then I have a print line: print("[Essentials Admin]: Player loaded!") that also registers. But after that print line, is the Player.Chatted event, and it doesn’t seem to be able to recognize it in-game, but perfectly fine within studio.
I had this exact same issue when me and my friend were making our admin system. Our solution was to put the Players.PlayerAdded event outside of the return function, or whatever you have.
for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
PlayerAdded(Player)
end
game:GetService("Players").PlayerAdded:Connect(PlayerAdded)