So recently I have been having issues with loading player data in my game and found that it was because requiring my DataStore2 module was yielding the execution of my PlayerAdded event. So I changed the code to require the module inside of the event instead, which seems to work - just feels gross.
Players.PlayerAdded:connect(function(plr)
print("Loading data for " .. plr.Name)
local DataStore2 = require(1936396537)
end)
Is requiring a module inside of a PlayerAdded event bad practice? It feels wrong, but I think I need to do this in order to ensure the PlayerAdded event is run as quickly as possible without yielding for the module to load outside of it.