I have an upgrade script. The 1st cost is 17. I can buy it for 17 but I can keep buying it for 17, yet the cost value is actually raising and more than 17. How come the script isn't detecting the value change?
upgrade script:
UpgradeBackpack.OnServerInvoke = function(player)
local cost = player.UpgradeCosts.BackpackUpgrade
if cost.Value <= player.leaderstats["Coins"].Value then
player.leaderstats["Coins"].Value = player.leaderstats["Coins"].Value -cost.Value
player.backpack.WeightLevel1.Value = player.backpack.WeightLevel1.Value + 1
return true
else
cost.Changed:Connect(function()
if cost.Value <= player.leaderstats["Coins"].Value then
player.leaderstats["Coins"].Value = player.leaderstats["Coins"].Value -cost.Value
player.backpack.WeightLevel1.Value = player.backpack.WeightLevel1.Value + 1
return true
else
return false
end
end)
end
end

5 comments
Because it's never reaching the 'else' part of the condition?
Can you possibly help? How do i make it reach the else part
The value has to be greater than the value in leaderstats. Simple as that.
Yeah, it does that. But the first cost is 17. I get 17 coins buy it boom done. lol. And I check, and the cost value then changes to 25. But I can buy the upgrade when I have 17 coins still though
Nevermind, I fixed it by firing a remote function to change the cost value before upgrading and it is fixed