In Part 1, we set up plots and assigned them to players when they joined. Now, we’ll give players the ability to buy items for their Tycoon using buttons.
Step 1: Create a Button
- Insert a Part into your game (this will be your button).
- Shape: Square
- Color: Red
- Anchored = true
- CanCollide = true (optional, gives a “step-on” feel).
- Rename it
Button
. - Add a Tag called
Button
. (In the Properties → Tags section, click ➕ and typeButton
).
This button will be the first purchase in your Tycoon.
Step 2: Add Text to the Button
- Select the button → click ➕ → insert a BillboardGui.
- Inside the BillboardGui, insert a TextLabel.
- Adjust the BillboardGui:
Adornee
= the ButtonSize
={3,0},{3,0}
StudsOffsetWorldSpace
={0,3,0}
(moves text above the button)LightInfluence = 0
(always visible).
- Adjust the TextLabel:
Size
={1,0},{1,0}
BackgroundTransparency = 1
TextScaled = true
- Example Text:
"Starter Item"
TextColor3 = White
FontFace = FredokaOne
- (Optional) Insert a UIStroke for outlining the text.
Step 3: Create the Item to Buy
- Add an object/model to serve as the item (example: a poster, machine, wall, etc.).
- Position it where you want it to appear in the Tycoon.
- In Properties → Attributes, add a new Number attribute called
ID
.- Example:
ID = 1
- Each item in your Tycoon must have a unique ID.
- Example:
Step 4: Connect Button to Item
- Select your Button.
- In Attributes, add a new Number attribute:
IDofItemToUnlock = 1
(This must match the ID of the item you want the button to unlock).
Step 5: Organize with a Template Plot
To make your Tycoon scalable, organize everything in a Template Plot:
- Create a new Part → rename to
TemplatePlot
. - Inside it, create two folders:
Buttons
(move your Button inside)Items
(move your Item inside).
- Keep the TemplatePlot separate from the player plots (this acts like your “blueprint”).
Step 6: Update the Plot Handler Script
In ServerScriptService
, edit your PlotHandler so that when a player is assigned a plot, the buttons from the TemplatePlot get cloned and positioned correctly.
Key logic:
- Get the relative position of each button in the TemplatePlot.
- Place it in the same relative position inside the player’s plot.
- Do the same later for items.
Step 7: Make Buttons Work (Purchasing Items)
When a player steps on a button:
- Check if the touch came from a player.
- Verify the player is the owner of the plot.
- Get the button’s attribute:
IDofItemToUnlock
. - Find the matching item in the TemplatePlot → Items folder.
- Clone the item into the player’s Items folder.
- Place it in the correct relative position on the plot.
- Destroy the button so it can’t be pressed again.
Example Snippet (simplified logic)
button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not player then return end
-- Check ownership
if plot:GetAttribute("Owner") ~= player.UserId then return end
-- Get Item ID
local itemToUnlockID = button:GetAttribute("IDofItemToUnlock")
if not itemToUnlockID then return end
-- Find Item in Template
for _, item in pairs(templateItems:GetChildren()) do
if item:GetAttribute("ID") == itemToUnlockID then
local clone = item:Clone()
clone.Parent = itemsFolder
-- Position it relative to the plot
clone.CFrame = plot.CFrame:ToWorldSpace(
templatePlot.CFrame:ToObjectSpace(item.CFrame)
)
break
end
end
-- Remove button after use
button:Destroy()
end)
Step 8: Test It
- Run your game.
- Step on the button.
- The item should appear in the correct location.
- The button should disappear (so it can’t be reused).
Recap
- Buttons let players buy items in their Tycoon.
- Each button and item is linked using a unique
ID
. - Items and buttons are stored in a TemplatePlot and cloned into real plots.
- Items appear when their button is stepped on.
- Buttons are destroyed after purchase to prevent repeats.
Next Step
Now that buttons and purchases are working, the next part will add a money system and require players to spend currency before unlocking items.