How can i repair my game's lobby system?

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

  1. I wanna make my game have a lobby system that teleports you from a level to another and can include more players in it, however, the knowledge i detain just doesn’t cut it and i run into errors.

  2. My problem is that i can’t teleport players from a lobby to a place
    image

The script is as following

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local TeleportService = game:GetService(“TeleportService”)
local teleportOptions = Instance.new(“TeleportOptions”)
local PlayersToTeleport = {}

ReplicatedStorage.Teleport.OnServerEvent:Connect(function(blablabla, LobbyNr, SelectedLv)

for	i, v in pairs(ReplicatedStorage.OccupiedLoobies["lobby"..LobbyNr]:getChildren()) do
	
	if v:IsA("StringValue") and v.Value ~= nil and i <= ReplicatedStorage.OccupiedLoobies["lobby"..LobbyNr]["nrOfPlayer"..LobbyNr].Value then
		local Sufix = "p"..i
		PlayersToTeleport[Sufix] = game.Players:FindFirstChild(v.Value).Name
		print(game.Players:FindFirstChild(v.Value).Name)
	end
end

wait(60)

--local reservedServerAccessCode = TeleportService:ReserveServer(SelectedLv)
teleportOptions.ShouldReserveServer = true;

--TeleportService:TeleportToPrivateServer(SelectedLv, reservedServerAccessCode, game.Players:GetChildren(PlayersToTeleport))
TeleportService:TeleportAsync(SelectedLv, game.Players:GetChildren(PlayersToTeleport), teleportOptions)
end) 				
  1. nothing seems to work as far as i took it
1 Like

:GetChildren doesn’t take any args. Try this:

ReplicatedStorage.Teleport.OnServerEvent:Connect(function(blablabla, LobbyNr, SelectedLv)
    local players = {}
	for	i, v in pairs(ReplicatedStorage.OccupiedLoobies["lobby"..LobbyNr]:GetChildren()) do
		
		if v:IsA("StringValue") and v.Value ~= nil and i <= ReplicatedStorage.OccupiedLoobies["lobby"..LobbyNr]["nrOfPlayer"..LobbyNr].Value then
			local Sufix = "p"..i
			PlayersToTeleport[Sufix] = game.Players:FindFirstChild(v.Value).Name
			table.insert(players, game.Players:FindFirstChild(v.Value))
		end
	end
	
	wait(60)
	
	--local reservedServerAccessCode = TeleportService:ReserveServer(SelectedLv)
	teleportOptions.ShouldReserveServer = true;
	
	TeleportService:TeleportAsync(SelectedLv, players, teleportOptions)
end) 	

it doesn’t teleport me, i’ll send you a test place of it
HAwfw.rbxl (77.4 KB)

I’m unfortunately unable to access studio atm, but could you say what is SelectedLv? Also where are you trying to tp the players to?

SelectedLv is the place id and the players have to be tp’ed to a place in the experience