Hey! I’ve been trying to make a system that waits for all players to load into the game, and then resumes. With loaded, I mean they’re off the Roblox loading screen and can see the game world.
My current solution works fine in studio but then breaks in the Roblox player if you load for quite a while.
ReplicatedFirst local script:
local assets = {
game:GetService("StarterPlayer"),
game:GetService("ReplicatedStorage"),
}
for i = 1, #assets do
game:GetService("ContentProvider"):PreloadAsync({ assets[i] })
end
game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("PlayerLoaded"):FireServer()
Script in ServerScriptService:
while #players:GetPlayers() < 1 do wait() end
local Loaded = 0
local MinimumLoad = #players:GetPlayers()
local timeout = 60 -- Change this to how many seconds until loading is made complete regardless of wether or not everyone has loaded.
game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("PlayerLoaded").OnServerEvent:Connect(function(p)
Loaded = Loaded + 1
end)
local start = tick()
while Loaded < MinimumLoad and (tick() - start) < timeout do wait() end
warn("Finished waiting for players!")
(notable is that there’s another repeat until loop before above)
The other post’s I’ve found didn’t really help me so that’s why I’m here.