So I've built an upgrader for my tycoon money blocks, and it executes the "Upgraded" function, but then when it gets to the "Add Money" function, it doesn't do anything. I feel like I might have phrased the code wrong but I'm not sure.
local block = script.Parent
local Tycoon = game.Workspace.Tycoon
local MoneyMaker = Tycoon.Foundation.Conveyor.MoneyMaker
local MoneyBlock = Tycoon.MoneyBlock
local owner = Tycoon.Owner.Value
local upgrader = Tycoon.Upgrader.MoneyUpgrader
local upgraded = false
local cash = game.Players[owner].leaderstats.Cash.Value
local function Upgraded(hitPart)
local upgraded = true
print("Upgraded!")
end
upgrader.Touched:connect(Upgraded)
local function AddMoney(hitPart)
if upgraded == true then
print("upgrade complete!")
cash = cash + 10
MoneyBlock:Destroy()
if upgraded == false then
print("no upgrade!")
cash = cash + 5
MoneyBlock:Destroy()
end
end
end
MoneyMaker.Touched:connect(AddMoney)
Thanks for the help!

1 comment
Thanks, but the if/else statement still won't execute for some reason