Menu
CoddyTech

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) --> 10

Balancing a tycoon means changing those numbers again and again, so they live in one place.

challenge icon

Challenge

Easy

Your Tycoon Script is in ServerScriptService.

  1. Load the settings with require(game.ReplicatedStorage.Settings).
  2. Print what an ore is worth, built from Settings.OreValue: the Output should read Ore is worth 10 Cash.
  3. When a player joins, give them a leaderstats Folder holding an IntValue named Cash.

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)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Roblox Game: Factory Tycoon