How to Create a Roblox Tycoon (Part 3: Adding Cash & Purchases)

In Part 2, we created buttons that let players unlock items. But right now, they’re free — which makes the Tycoon too easy! In this part, we’ll add cash (currency) so players need to spend money to buy items.


Step 1: Set Up Leaderstats (Player Data)

We’ll store each player’s money in a leaderboard (the top-right corner of the screen).

  1. In ServerScriptService, insert a new Script.
  2. Rename it: Data.
  3. Add this code:
-- Data Script (handles player stats like money)
game.Players.PlayerAdded:Connect(function(player)
    -- Create Leaderstats folder (must be lowercase "leaderstats")
    local folder = Instance.new("Folder")
    folder.Name = "leaderstats"
    folder.Parent = player

    -- Create Cash value
    local cash = Instance.new("IntValue")
    cash.Name = "Cash" -- appears on leaderboard
    cash.Value = 0     -- start with 0
    cash.Parent = folder
end)

Now when you press Play, you’ll see a leaderboard in the top-right corner with “Cash = 0.”


Step 2: Add Prices to Buttons

Each button should have a price so players must pay to unlock items.

  1. Select your Button in the Explorer.
  2. In Properties → Attributes, click ➕.
  3. Add:
    • Name = Price
    • Type = Number
    • Example Value = 50

This means unlocking this button costs 50 Cash.


Step 3: Update Plot Handler Script

Go back to your PlotHandler script (where you detect button touches).
Find the section where the player touches the button and add:

-- Get price from button
local price = button:GetAttribute("Price")

-- If no price set, item is free
if price and player.leaderstats.Cash.Value < price then
    warn("You cannot afford this item!")
    return
end

-- Deduct price from Cash (only if price exists)
if price then
    player.leaderstats.Cash.Value -= price
end

Step 4: Test the System

  1. Press Play.
  2. Step on the button with 0 Cash.
    • You should see a warning: “You cannot afford this item!”
    • The item won’t appear.
  3. Give yourself Cash (in Server View only):
    • Switch to Server mode in Studio.
    • In Explorer → Players → [YourName] → leaderstats → Cash → set value to 500.
  4. Switch back to Client mode.
  5. Step on the button again.
    • The item appears
    • Your Cash decreases (e.g., from 500 → 450).

Recap

  • Created a leaderstats system to track Cash.
  • Added a Price attribute to buttons.
  • Checked if players have enough money before unlocking items.
  • Deducted money when they buy items.

Next Step

Right now, players start with 0 Cash. In the next part, we’ll create a dropper system so players can earn money automatically and keep upgrading their Tycoon.