Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the script not detecting the value change?

Asked by 4 years ago

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
0
Because it's never reaching the 'else' part of the condition? DeceptiveCaster 3761 — 4y
0
Can you possibly help? How do i make it reach the else part ChefDevRBLX 90 — 4y
0
The value has to be greater than the value in leaderstats. Simple as that. DeceptiveCaster 3761 — 4y
0
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 ChefDevRBLX 90 — 4y
0
Nevermind, I fixed it by firing a remote function to change the cost value before upgrading and it is fixed ChefDevRBLX 90 — 4y

Answer this question