How to make a wait for players to load system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I an trying to make a game similar to story games where there is a lobby and players
get sent to a place where the real game begins.

  1. What is the issue? Include screenshots / videos if possible!

There are multiple types of private servers(1 player, 3 players, 5 and 10) and for the game
to begin, I want to make sure that atleast half of the people sent have loaded. However, I don’t
know how to send the value of the amount of players from the lobby to the main game.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

On all the solutions I found to wait for everyone to load, they were assuming the amount of players is always the same.

The only thing I can think of is to make multiple places.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Script where the player is sent

local count = 30
local function CountAndTeleport()
if countDebounce == false then
countDebounce = true
repeat
task.wait(1)
count -= 1
CountDown.SurfaceGui.TextLabel.Text = tostring(count)
until count == 0 or #Table == 0

local Code = tpService:ReserveServer(id)
--Where I am trying to send the amount of players in the table to the place
tpService:TeleportToPrivateServer(id, code, Table)
countDebounce = false
count = 30
Countdown.SurfaceGui.TextLabel.Text = count
end
end

Trigger.Touched:Connect(CountAndTeleport)
Trigger.Touched:Connect(addToTable)


Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

What I recommend

Well, Once the players are sent to the server: Have a UI inside the game while the players load. Once a player loads from the local side, make it fire an event. Have the server keep track of who has fired the events, you can do this with the values: Once a player has fired the event, change a value in the player and then check if all the values are checked on EVERY player.

Once every player has loaded in (all the values are checked), let everyone play the game!

I would also recommend sending a table of each player whos expected in the server to the private server, which the private server can pick up on using TeleportService:GetLocalPlayerTeleportData()
If not all the players are found in the server, it continues to wait a certain amount of time before it just continues with the game: assuming the user disconnected or left before the teleportation was complete.

AND ANOTHER THING,
I would recommend having parts of the script for things like… if a player rejoins after they disconnect, where they can be teleported back to the server and it wont force everyone to wait for loading again while they load in.

SHORT ANSWER

Short answer to ONLY what you asked in the code, use put # before the table and it will send the index amount of the table.

2 Likes

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