Waiting for players

Hello. I recently made a map loading system where it show a preview of the map and the mapname. I got it working where if the map loads, the player can start playing in the round but I was wondering if there was a way to wait for all players to load, if every player has finished loading then the round starts.

I don’t want it where the other players are playing while one player is still stuck on the map loading screen and taking forever to load.

Examples are highly appreciated thanks.

An Example of what i’m talking about would be something like this in flood escape 2:

1 Like

This script waits until the players have loaded before starting next lines of code:

local Players = game:GetService("Players")

repeat
	Players.PlayerAdded:Wait()
until #Players:GetPlayers() == 2 -- Wait for 2 players.

-- Further code will run below after this condition was met
3 Likes

Sorry but this is not quite what i’m looking for. I have a map loading gui that players can see and when the client gets loaded, i don’t want the gui to disapear instead i want it to wait for other players to load and show the amount of players that have loaded before starting the game.

1 Like

Try this, maybe:

Probably not what you are looking for.

2 Likes

Something similiar to that but not really what i’m looking for sorry.

2 Likes

I would say just use the normal PlayerAdded event and check with a variable whether you have enough players or not. If you do, then fire a remote to all clients that either the round is starting or another player joined and updates the numbers.

Here is an example code:

local Players = game:GetService("Players")
local MinAmount = 3
local Amount = 0

Players.PlayerAdded:Connect(function(Player)
  Amount += 1

  if Amount == MinAmount then
    -- round is starting
  else
    -- we just have an extra player, round isn't starting
  end
end)

Players.PlayerRemoving:Connect(function(Player)
  Amount -= 1
end)
2 Likes

sorry but this is not what i’m looking for

1 Like

I imagine that you are stressed because nobody understands you, that’s why I participate.
make a client script which checks the player’s status (if he is inside the map or not) and when the local script detects that the player is already in charge (character or whatever you need) it sends a remote event to the server and the server will add to a value and have the server detect when the value goes to 11 (your limit) do whatever it has to do

4 Likes

I kinda realized this sooner but thanks for also telling me about this.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.