The plan
A tycoon is a machine that makes money while you watch, and buttons that make it faster. You'll write three scripts:
- a dropper that makes a coin every few seconds
- a collector that counts coins when they land
- an upgrade button that spends money to speed up the dropper
1. Build the layout
Add a tall part called Dropper, a sloping part under it, a flat part at the bottom called Collector, and a TextLabel on screen called Money. Press Play and make sure you can walk around it.
2. The dropper
Add a Script to Dropper:
local dropper = script.Parent
dropper:SetAttribute("Every", 2) -- seconds between coins
while true do
local coin = Instance.new("Part")
coin.Name = "Coin"
coin.Size = Vector3.new(1, 1, 1)
coin.Color = Color3.fromHex("#f7e04f")
coin.Position = dropper.Position + Vector3.new(0, 3, 0)
coin.Parent = workspace
task.wait(dropper:GetAttribute("Every"))
end
Play. Coins should fall out of the top, roll down the slope and pile up on the collector.
3. The collector
Add a Script to Collector:
local pad = script.Parent
local label = game:GetService("StarterGui"):FindFirstChild("Money", true)
local money = 0
pad.Touched:Connect(function(other)
if other.Name ~= "Coin" then return end
other:Destroy()
money += 1
label.Text = "$" .. money
workspace:SetAttribute("Money", money)
end)
4. The upgrade button
Add a part called Upgrade near the collector with a Script:
```luau
local button = script.Parent
local dropper = workspace:FindFirstChild("Dropper")
local price = 10
button.Touched:Connect(function(other)
if not other:IsA("Player") then return end
local money = workspace:GetAttribute("Money") or 0
if money < price then return end
workspace:SetAttribute("Money", money - price)
dropper:SetAttribute("Every", dropper:GetAttribute("Every") / 2)
price = price * 2
end)
```
The button and the collector both use the Money attribute on workspace. That's how two scripts share one number.
5. Make it yours
- A second dropper that the button unlocks.
- A label on the button that shows the price.
- A sound when a coin lands (add a Sound, then
sound:Play()).
Done when
- Coins drop, get counted and disappear.
- The button charges money and speeds things up.
- You can explain why the collector destroys the coin before counting.