For example, if a player joins, I have a large datastore to load for them. If a player joins while that function is running, I want it to run more than once at the same time, once per player. How would I do this?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
print(player.Name)
end)
I think you’re over complicating this, if the “PlayerAdded” event fires twice at the same time due to two players joining at the same time then its connected callback function will execute at the same time in two separate threads, one for each player.
To put it simply, callback functions connected to events will execute in their own threads of execution when those events fire (separate from the main thread which handles the execution of the entire script).