We use cookies on this site to enhance your user experience

Making a Lobby

Making a Lobby

Jun 14 2019, 2:14 PM PST 5 min

When making your game, you may want to create a game lobby so that:

  • New users do not join a round that’s in progress
  • Once players die, they are eliminated from the round instead of respawning

Fortunately, creating such a lobby can be easily done with scripting! In this tutorial, you will learn how to make a game lobby that holds players until the next round begins and then teleports them to the game arena.

Getting Started

You will need to take the following steps:

  1. Create a lobby in Roblox Studio using the materials of your choice.
  2. Add a spawn location to your lobby and ensure it is the only spawn location on your map.
  3. Place a block titled TeleportTarget where you want the players to be teleported.
  4. Place the below script in your Workspace:
local oldMessage = ""
local minPlayers = 2

function teleportAllPlayers()
	local target = CFrame.new(workspace.TeleportTarget.Position)
	for i, player in ipairs(game.Players:GetChildren()) do
		player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
		player.Playing.Value = 1
		--add an offset of 5 for each character

function message(message)
	if oldMessage ~= message then
		oldMessage = message

function playersCurrentlyPlaying()
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.Playing.Value == 1 then return true end
	return false

			player.Playing.Value = 0

	local playing = Instance.new("IntValue", player)
	playing.Value = 0
	playing.Name = "Playing"
while(true) do
	if #game.Players:getPlayers() >= minPlayers then
		if playersCurrentlyPlaying() then
			message("Waiting for the current game to end...")
			message("There are enough players for a new game!  Teleporting...")
	else message("Waiting for more players...") end


Minimum Players

If you want to change the minimum number of players, you can do so by changing the code local minPlayers = 2 to have any number you like.

Server Messages

In this script, the function message(message) is used to send messages to players. Right now, it only outputs to the console, but you can easily change it to display messages however you want. For example, you could display messages using a ScreenGUI TextLabel.

Another thing you could do is broadcast certain messages only to players who are in the lobby and other messages to all players. This script already uses the value Playing as a child of each player, so you can easily add behavior for those two groups of players.

Adding More Functionality

Want to have multiple team teleport locations? Want to have people teleported back to the lobby before they die? Feel free to modify this script to do whatever you like - the possibilities are endless!

  • gameplay
  • coding