I am not sure I understand from your post whether you want it to be multiplied by 2.2, and then 2.2 again, or just have 2.2 multiplied by a number.
If you want to make it multiplied by a number, you can do that with an inline if statement.
local price = if(player.Values.Upgrades.Value == 0) then 100 else 100 * 2.2 * player.Values.Upgrades.Value
If you want to multiply it by powers of 2.2, that would be a geometric series, which means that the value a(n) = a1 * q^(n-1):
In code, a1 is the first term of the series, or in your case, the initial price. The q is the quotient of the geometric series, which in this case is your multiplier - 2.2, and n is the series current term, which in this case is your upgrades values.
In mathematic terms:
Price(upgrade) = initialPrice * (2.2)^(upgrades)
local price = 100 * (2.2)^(player.Values.Upgrades.Value)
If you really don’t want to use IF statements you can do the following,
If you are using tables to store data you can do this:
First create your table but don’t include the upgrade value
local data={
Upgradename="string",
UpgradeType="normal"
}
local function includekey(tbl)
tbl.UpgradeValue=1
return 1
end
then when you need to calculate the price of the upgrade you can do local price = 100*2.2*(data.upgradevalue or includekey(data)) so what happens is that you try to index a key that isn’t in the table so it returns nil and includekey will be called because of or and it will return 1 so it will be considered for the multiplication
If you are using Int Values you can do the same thing but you need to create another function,have upgrade intvalue as nil as in don’t create it yet and do a pcall like this
function createint(s,p)
local a= Instance.new("IntValue")
a.Parent=p a.Name=s
return 1
end
local suc,val=pcall(function() return player.data.upgrade )
local upgradeval= val.Value or createint("Upgrades",player)
local price = 100*2.2*upgradeval