How to Create a Roblox Tycoon (Part 6: Unlocking Dependent Buttons)

In the last part, we added data saving so progress is remembered when players leave and rejoin. Now, let’s make our Tycoon feel more structured by creating buttons that only appear once another item is purchased.

For example:

  • The Conveyor button is visible at the start.
  • Once the Conveyor is bought, the Dropper button appears.
  • Later purchases can unlock more buttons in sequence.

Step 1: Add a “Hidden” Attribute to Buttons

We want certain buttons to be invisible until unlocked by another.

  1. Select a button you want hidden at the start.
  2. In the Properties panel → Attributes, add:
    • Name: Hidden
    • Type: Boolean
    • Value: true

This makes the button invisible and non-interactable when the Tycoon loads.


Step 2: Add an Attribute for Dependent Unlocks

On the parent button (e.g., Conveyor), we’ll specify which buttons it should reveal.

  1. Select the Conveyor button.
  2. Add a new attribute:
    • Name: ItemIDsToAppearOnceBought
    • Type: String
    • Value: 2 (the ID of the Dropper button)
  3. Why a string? Because you may want to unlock multiple buttons at once. For example:
2,3,4,5

This means buying the Conveyor would reveal buttons with IDs 2, 3, 4, and 5.


Step 3: Hide Buttons in Script

In your PlotHandler script (where you spawn buttons), modify the setup so hidden buttons don’t show initially:

if button:GetAttribute("Hidden") then
    button.Transparency = 1
    button.CanTouch = false
    button.BillboardGui.Enabled = false
end

This ensures players can’t interact with them until unlocked.


Step 4: Unlock Buttons After a Purchase

When a player successfully buys an item, we’ll check if that button should reveal more buttons.

  1. After deducting cash and confirming purchase, add:
local idsString = button:GetAttribute("ItemIDsToAppearOnceBought")
if idsString then
    -- Split the string into individual IDs
    local itemIDs = string.split(idsString, ",")

    for _, itemId in ipairs(itemIDs) do
        -- Convert from string to number
        itemId = tonumber(itemId)

        local unlockButton = GetButtonByItemID(player, itemId)
        if unlockButton then
            unlockButton.Transparency = 0
            unlockButton.CanTouch = true
            unlockButton.BillboardGui.Enabled = true
            unlockButton:SetAttribute("Hidden", false)
        end
    end
end

Step 5: Helper Function (Find Button by Item ID)

At the top of PlotHandler, create this helper:

local function GetButtonByItemID(player, itemId)
    local plot = GetPlot(player)
    if not plot then return end

    for _, btn in ipairs(plot.Buttons:GetChildren()) do
        local id = btn:GetAttribute("IDOfItemToUnlock")
        if id and id == itemId then
            return btn
        end
    end
end

This searches the player’s plot for the button with the matching ID.


Step 6: Fix String vs Number Bug

Since ItemIDsToAppearOnceBought is a string, we must convert each split value into a number (tonumber(itemId)).
Without this, comparisons will fail and buttons won’t unlock properly.


Step 7: Persist Unlocks With Data Saving

Earlier we built saving/loading with ProfileService. But when rejoining, hidden buttons might still stay hidden.

To fix this:

  • After loading items in your plot, re-run the same unlock logic used after a purchase.
  • If an item was already bought, also make its dependent buttons appear.

Step 8: Add Item Names to Billboard GUI

To show the correct name above each button:

button.BillboardGui.TextLabel.Text =
    GetItemFromTemplatePlot(button:GetAttribute("IDOfItemToUnlock")).Name
    or ""

Now buttons will display the proper item name automatically.


Recap

  • Added a Hidden attribute to keep some buttons invisible.
  • Added ItemIDsToAppearOnceBought so certain purchases reveal new buttons.
  • Updated script to hide/show buttons at the right time.
  • Fixed the string-to-number bug when parsing IDs.
  • Ensured hidden/unlocked buttons also work when loading saved data.