Menu
CoddyTech

The Game Script

Lesson 1 of 20 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) --> 5

With the settings in one module, one change tunes the whole game, and every script that needs them reads the same table.

challenge icon

Challenge

Easy

Start the game's server Script, RoundManager.

  1. Load the settings: local Settings = require(game.ReplicatedStorage.Settings).
  2. Print "Rounds last " .. Settings.RoundLength .. " seconds".
  3. When a player joins, give them a Folder named leaderstats holding an IntValue named Wins.

Press Play: the Output reads Rounds last 15 seconds, and Wins shows 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)

All lessons in Roblox Game: Disaster Survival

Practice on your own: Roblox playground