The Game Script
Lesson 1 of 18 in Coddy's Roblox Game: Disaster Survival course.
In this course you build one game, a lesson at a time: Disaster Survival. Players wait in a lobby, get teleported to an island, and try to outlast a flood, a meteor shower or a shrinking floor. Whoever is still standing when the time runs out wins.
A whole game like this runs from one Script in ServerScriptService. Yours is called RoundManager, and every lesson adds a feature to it.
The numbers a game designer tunes, such as how long a round lasts, live in a ModuleScript. This place has one in ReplicatedStorage named Settings. A ModuleScript returns one value, here a table, and require runs it and hands you that value:
local Settings = require(game.ReplicatedStorage.Settings)
print(Settings.Intermission) --> 5With the settings in one module, one change tunes the whole game, and every script that needs them reads the same table.
Challenge
EasyYour RoundManager Script is in ServerScriptService.
- Load the settings:
local Settings = require(game.ReplicatedStorage.Settings). - Print how long a round lasts, built from
Settings.RoundLength. The Output should readRounds last 15 seconds. - When a player joins, give them a Folder named
leaderstatsholding an IntValue namedWins.
Press Play to see Wins on the leaderboard, then Check.
Try it yourself
-- RoundManager: the Script that runs your whole game.
local Players = game:GetService("Players")
-- 1. Load the game's settings: require the ModuleScript
-- game.ReplicatedStorage.Settings
-- 2. Print how long a round lasts, using Settings.RoundLength
-- 3. Give every player a Wins value on the leaderboard
-- (a Folder named leaderstats holding an IntValue named Wins)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.