I am trying to make a shop, and the player can choose what amount of items to buy and the price changes along with the amount. Example: When the player selects, say 2 items, and the price of 1 item is $10, then the player will have to pay $10 x 2 = $20. However, when I try this, it reduces a lot more coins than it should. Example: when I select $20 dollars for 2 items, it reduces something like 100-200. Can you please help?
There are no errors.
Script:
function buy(v)
if selectedTemp ~= nil then
local coins = player.leaderstats.Coins
local newval = (amnt.Value * v.Price.Value)
print(amnt.Value)
if coins.Value >= newval then
local new = false
if new ~= true and new == false then
new = true
coins.Value -= newval
player.ItemsInStock[v.Name].Value += (amnt.Value)
wait(.2)
new = false
end
end
end
end
Prints:
15:17:31.059 ▼ 1 (x5) - Client - MainScript:25
15:17:31.059 1
15:17:31.060 1
15:17:31.061 1
15:17:31.062 1
There are no errors in the output. Thank you all!