The Tower Script
Lesson 1 of 21 in Coddy's Roblox Game: Endless Tower course.
In this course you build a tower obby: every round a new tower is stacked from random stages, lava rises from below, and the first to the top wins. By the end it has spinners, vanishing steps, conveyors, lasers, bounce pads, checkpoints and best times.
One Script in ServerScriptService, called Tower, runs the game. The numbers that balance it (how many stages, how fast the lava rises) live in a ModuleScript, ReplicatedStorage.Settings, and require hands you the table it returns:
local Settings = require(game.ReplicatedStorage.Settings)
print("Rounds last " .. Settings.RoundLength .. " seconds") --> Rounds last 120 secondsTuning an obby means changing those numbers again and again, so they live in one place.
Challenge
EasyStart the game's one Script, Tower.
- Load the settings:
local Settings = require(game.ReplicatedStorage.Settings). - Print
"Each tower has " .. Settings.StageCount .. " stages". - When a player joins, give them a
leaderstatsFolder holding an IntValue namedWins.
Press Play: the Output reads Each tower has 5 stages and Wins shows on the leaderboard. Then Check.
Try it yourself
-- Tower: the Script that runs your whole game.
local Players = game:GetService("Players")
-- 1. Load the settings: require the ModuleScript
-- game.ReplicatedStorage.Settings
-- 2. Print how many stages a tower has, using Settings.StageCount
-- 3. Give every player a Wins value on the leaderboard
-- (a Folder named leaderstats holding an IntValue named Wins)
All lessons in Roblox Game: Endless Tower
Practice on your own: Roblox playground