Skip to Content

A round system

Structure of the Toolbox Round System: intermission loop, map selection from Storage, teleporting and cleanup.

Quick start

  1. Open the Toolbox, switch to Scripts and insert Round System.
  2. Storage › Maps contains four template baseplates: Red Map, Blue Map, Yellow Map and Purple Map.
  3. Replace or edit them with your own map models.
  4. Press Play.

The world's own baseplate acts as the lobby. After the intermission a random map is cloned from Storage and every player is teleported to it. When the round timer expires, players return to the lobby and the clone is destroyed.

Configuration

Parameters are value objects inside the Round System script.

ValueDefaultDescription
LobbyTime15Intermission length in seconds.
RoundTime90Round length in seconds.
MinPlayers1Minimum players required to start a round.
LobbyPosition0, 4, 0Teleport target after a round.
MapPosition0, 0, 400Position maps are moved to with MoveTo.
MapsFolderMapsPath in Storage to the model holding the maps. Nested paths use /, for example Maps/Hard.

The map name shown in announcements is the model's Name.

Implementation

Resolving the maps folder

local Storage = game:GetService("Storage")

local function mapList()
	local folder = Storage
	for name in string.gmatch(setting("MapsFolder", "Maps"), "[^/]+") do
		if folder then
			folder = folder:FindFirstChild(name)
		end
	end
	if not folder then
		return {}
	end
	return folder:GetChildren()
end

Countdown

Countdowns use game:Message, which updates a persistent top bar instead of the full-screen announcement:

local function countdown(label, seconds)
	for left = seconds, 1, -1 do
		game:Message(label .. " " .. left)
		task.wait(1)
	end
	game:Message("")
end

Round loop

local chosen = maps[math.random(1, #maps)]
local map = chosen:Clone()
map:MoveTo(setting("MapPosition", Vector3.new(0, 0, 400)))

game:Announce("Round starting on " .. chosen.Name .. "!", 3)
sendAll(findSpawn(map) or mapPosition + Vector3.new(0, 4, 0))
countdown("Time left:", setting("RoundTime", 90))

game:Announce("Round over!", 3)
sendAll(setting("LobbyPosition", Vector3.new(0, 4, 0)))
map:Destroy()

Clone() instantiates the map from Storage and leaves the original in place. Destroy() removes the clone and stops any scripts it started.

Map requirements

  • Each map is a model directly inside the maps folder.
  • A part named Spawn directly inside the map sets the teleport target. Without one, players are sent to MapPosition.
  • Scripts and NPCs inside a map start when the map is cloned.

Extensions

  • Award a win stat to the last surviving player with Player:SetStat.
  • Implement map voting with Remote and a client UI.
  • Place NPCs inside a map for wave-based rounds.

On this page