ocal tycoon = script.Parent.Parent.Parent
local UpgradeCall = 5 -- Referring to the upgrade in the Upgrades script.
local ButtonUpgradeCall = 0 -- Referring to the button upgrade in the ButtonUpgrades script.
local Cost = 300 -- How much it costs to get this upgrade.
local IncomeIncrease = 0 -- This is the amount that will be added to the amount of money the player receives every few seconds.
local active = false
function SpecialTask()
-- Anything else you'd like the script to do.
end
function fix(num)
-- Put the comma in numbers that are greater than 1,000:
local txt = ""
if (num > 999) then
local c = tostring(num)
txt = string.sub(c,1,#c-3) .. "," .. string.sub(c,#c-2)
else
txt = num
end
return txt
end
function modelName()
if (string.find(script.Parent.Name," -- $")) then return end
if (string.find(script.Parent.Name," -- FREE")) then return end
if (Cost ~= 0) then
if (Cost > 999) then
local c = tostring(Cost)
script.Parent.Name = script.Parent.Name .. " -- $" .. string.sub(c,1,#c-3) .. "," .. string.sub(c,#c-2)
else
script.Parent.Name = script.Parent.Name .. " -- $" .. Cost
end
else
script.Parent.Name = script.Parent.Name .. " -- FREE"
end
end
function msg(txt,type,time,parent)
if (parent:findFirstChild("UpgradeMsg")) then return end
delay(0,function()
local m = Instance.new(type)
m.Name = "UpgradeMsg"
m.Parent = parent
m.Text = txt
wait(time)
m:remove()
end)
end
script.Parent.Head.Touched:connect(function(h)
local player = game.Players:GetPlayerFromCharacter(h.Parent)
if not (player) then return end
if (active) then return end
active = true
if (tycoon.Owner.Value ~= player) then
msg("This is not your " .. tycoon.Parent.NameOfTycoon.Value .. "!","Message",3,player)
active = false
return
end
if (player.leaderstats.Money.Value < Cost) then
msg("You need $" .. fix((Cost-player.leaderstats.Money.Value)) .. " more for this upgrade","Message",3,player)
active = false
return
end
player.leaderstats.Money.Value = player.leaderstats.Money.Value - Cost
tycoon.Call.Value = UpgradeCall
tycoon.ButtonCall.Value = ButtonUpgradeCall
tycoon.Income.Value = tycoon.Income.Value + IncomeIncrease
SpecialTask()
msg("Upgrade Complete","Message",2,player)
script.Parent.Head.CanCollide = false
script.Parent.Head.Transparency = 1
wait(3)
script.Parent.Parent:remove()
end)
game:service("RunService").Stepped:wait()
game:service("RunService").Stepped:wait() |