TYCOON
Upgrade System
Paste as a Script inside an upgrade button. Each buy spends more Cash than the last and raises UpgradeLevel. Cash Collector and Finish Line read that level as a multiplier.
-- Paste as a Script inside an upgrade button.
local Players = game:GetService("Players")
local BASE_PRICE = 50
local GROWTH = 1.6
local button = script.Parent
if not button or not button:IsA("BasePart") then
return
end
local busy: { [Player]: boolean } = {}
local function getCash(player: Player): IntValue?
local leaderstats = player:FindFirstChild("leaderstats")
local cash = leaderstats and leaderstats:FindFirstChild("Cash")
if cash and cash:IsA("IntValue") then
return cash
end
return nil
end
button.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player or busy[player] then
return
end
local cash = getCash(player)
if not cash then
return
end
local level = player:GetAttribute("UpgradeLevel") or 0
local price = math.floor(BASE_PRICE * (GROWTH ^ level))
if cash.Value < price then
return
end
busy[player] = true
cash.Value -= price
player:SetAttribute("UpgradeLevel", level + 1)
task.delay(0.4, function()
busy[player] = nil
end)
end)