Hello DevFourm, I have been working on a project where you click food to earn money, and you can use that money to upgrade to get more money when clicking (For now, the game is not public yet)
Anyways, I have a problem where when the player upgrades, I want it to remove the value of the upgrade price from the money value. When I do this, it returns a negative number which makes no sense since the upgrade value would always be greater than the money value.
Heres a video:
Heres the script in the upgrade button:
local VALUE = game.ReplicatedStorage.STATS.Upgrades.EatingSpeed
local BUTTON = script.Parent
local MONEY = game.ReplicatedStorage.STATS.Money
local UPGRADE_PRICE = script.Parent.VALUES.Price
local MULTIPLY_VALUE = script.Parent.VALUES.MULTIPLYBY
local LEVEL = script.Parent.VALUES.LEVEL
BUTTON.MouseButton1Click:Connect(function()
if MONEY.Value >= UPGRADE_PRICE.Value then
VALUE.Value += 8
UPGRADE_PRICE.Value += UPGRADE_PRICE.Value * 3
MULTIPLY_VALUE.Value += 1
LEVEL.Value += 1
MONEY.Value = MONEY.Value - UPGRADE_PRICE.Value -- !!!!The line I need help on!!!!
end
end)
-----------------------------------------------------
while wait() do
script.Parent.Text = "$"..UPGRADE_PRICE.Value
script.Parent.Parent.CURRENT_VALUE.Text = "Current Level: ".. script.Parent.VALUES.LEVEL.Value
end
Thanks for your help