The Tycoon Script
Lesson 1 of 18 in Coddy's Roblox Game: Factory Tycoon course.
In this course you build a tycoon, one of the most played kinds of Roblox game. Machines drop ore, a conveyor carries it to a collector, the collector pays Cash, and Cash buys more machines. By the end you have a full factory with upgrades, rebirths and saves.
The whole factory runs from one Script in ServerScriptService, called Tycoon. The numbers that balance the game (what ore is worth, how often it drops) live in a ModuleScript, ReplicatedStorage.Settings, and require hands you the table it returns:
local Settings = require(game.ReplicatedStorage.Settings)
print(Settings.OreValue) --> 10Balancing a tycoon means changing those numbers again and again, so they live in one place.
Challenge
EasyYour Tycoon Script is in ServerScriptService.
- Load the settings with
require(game.ReplicatedStorage.Settings). - Print what an ore is worth, built from
Settings.OreValue: the Output should readOre is worth 10 Cash. - When a player joins, give them a
leaderstatsFolder holding an IntValue namedCash.
Press Play, then Check.
Try it yourself
-- Tycoon: the Script that runs your whole factory.
local Players = game:GetService("Players")
-- 1. Load the settings: require the ModuleScript
-- game.ReplicatedStorage.Settings
-- 2. Print what one ore is worth, using Settings.OreValue
-- 3. Give every player a Cash value on the leaderboard
-- (a Folder named leaderstats holding an IntValue named Cash)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.