Check if game isnt loaded for other players

I have a GUI and the idea is that when a bunch of players join they are in a queue waiting for everyone to load in and while they are loading there is a spinning loading circle on their icon and when they finish loading into the game it becomes a checkmark. Is there a way to see when other players are still loading and when they finish?

2 Likes

if you want to do that you would need a script that would look something like this:

local loadedCount = 0
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function()
		loadedCount+= 1
	end)
end)
1 Like

You could pair this up with ContentProvider | Documentation - Roblox Creator Hub and use ContentProvider:PreloadAsync({}) to preload content in a loop, if the loop finishes fire a RemoteEvent to the server saying that it’s finished loading assets.

To prevent servers waiting forever for clients to fully load: Add a timeout for each player after the timeout expires mark them as ready anyways and if the player disconnects do not wait for them!
For example using Players.PlayerRemoving to listen for players disconnecting during the loading process.

2 Likes

From your description, I’m assuming you used a place teleport for all the players. The way I do this is:

  1. From the original place, teleport the players with data of the AMOUNT of players. You can read about doing this here.

  2. Detect the data when players load in. There’s also information about that in the article provided.

  3. Use a script like this:

local playersToLoad --sets an empty value
local loadedCount = 0 --players currently loaded
local alreadyDeclared = false --value to let us know if it's already been declared that the players are loaded so we dont declare it twice

game.Players.PlayerAdded:Connect(function(Player) --when a player joins
    local data = Player:GetJoinData().TeleportData --gets the player's join data (the data we sent)
    if tonumber(data) ~= nil then --if it's a number (which it should be) then
        playersToLoad = tonumber(data) --make the "playersToLoad" value the same
    end
	Player.CharacterAdded:Connect(function() --when the character loads (basically when the player finishes loading)
		loadedCount += 1 --make the loading count 1 higher
        if loadedCount >= playersToLoad and alreadyDeclared == false then --if the players loaded is high enough
            alreadyDeclared = true
            --do stuff when they're done
        end
	end)
end)

You may need to change it to your needs, but this just gives you a basic understanding of how you can do that.

2 Likes