How would I yield a thread until all players in a table that is assigned to a variable are have finished teleporting to that choosen map?
check every so often that all the players in the table are in Players have their character in the Workspace.
Like, When teleporting to another game?
Anyways, You could do what arqjanna said above , or something like this
task.wait(.1)
local players = game:GetService("Players")
local playersJoinedCount = 0
local requiredPlayersToStart = 2
local GameStarted = false
players.PlayerAdded:Connect(function()
if playersJoinedCount >= 0 then
if playersJoinedCount >= requiredPlayersToStart then
if not GameStarted then
GameStarted = true
local success, n_ = pcall(function()
-- start game logic, enable some boolean or remote event
end)
if success then
-- maybe another functions?
warn("done")
else
warn(n_)
GameStarted = false
playersJoinedCount = 0
end
end
else
playersJoinedCount += 1
warn("Still no Required players!, adding up")
end
end
end)