Im having issues with my cash purchasing script, when you purchase something it doesnt give you the amount that it displays on a textlabel. Ive tried a lot of things to fix this issue but I cant seem to get it working.
local MarketPlaceService = game:GetService("MarketplaceService")
local BronzeId = 1852179613
local SilverId = 1852179828
local GoldId = 1852179993
local DiamondId = 1852180091
function processReceipt(receiptInfo)
local plr = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
local playerCash = plr.leaderstats.Cash.Value
if not playerCash then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local leaderstats = plr:FindFirstChild("leaderstats")
if not leaderstats then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local playerGui = plr:FindFirstChild("PlayerGui")
if not playerGui then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local BronzeDisplay = plr.PlayerGui.CashShopGui.Frame.BronzeLabel
local BronzeAmount = BronzeDisplay and tonumber(BronzeDisplay.Text) or nil
local SilverDisplay = plr.PlayerGui.CashShopGui.Frame.SilverLabel
local SilverAmount = SilverDisplay or tonumber(SilverDisplay.Text) or nil
local GoldDisplay = plr.PlayerGui.CashShopGui.Frame.GoldLabel
local GoldAmount = GoldDisplay or tonumber(GoldDisplay.Text) or nil
local DiamondDisplay = plr.PlayerGui.CashShopGui.Frame.DiamondLabel
local DiamondAmount = DiamondDisplay or tonumber(DiamondDisplay.Text) or nil
print("Player:", plr)
print("leaderstats:", leaderstats)
print("playerCash:", playerCash)
print("BronzeAmount:", BronzeAmount)
print("SilverAmount:", SilverAmount)
print("GoldAmount:", GoldAmount)
print("DiamondAmount:", DiamondAmount)
if plr then
if receiptInfo.ProductId == BronzeId and BronzeAmount then
playerCash = playerCash + BronzeAmount
return Enum.ProductPurchaseDecision.PurchaseGranted
end
if receiptInfo.ProductId == SilverId and SilverAmount then
playerCash = playerCash + SilverAmount
return Enum.ProductPurchaseDecision.PurchaseGranted
end
if receiptInfo.ProductId == GoldId and GoldAmount then
playerCash = playerCash + GoldAmount
return Enum.ProductPurchaseDecision.PurchaseGranted
end
if receiptInfo.ProductId == DiamondId and DiamondAmount then
playerCash = playerCash + DiamondAmount
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end
MarketPlaceService.ProcessReceipt = processReceipt
Output:

Cash Textlabels Display script:
local fixedAmount = 200
local cashMultiplier = 1.5
local player = game.Players.LocalPlayer
local function calculateNewCashAmount(player)
local currentCash = player.leaderstats.Cash.Value
local newCashAmount = currentCash * cashMultiplier
return newCashAmount
end
player.leaderstats.Cash.Changed:Connect(function()
local player = game.Players.LocalPlayer
local newCashAmount = calculateNewCashAmount(player)
if player.leaderstats.Cash.Value <= 199 then
script.Parent.Text = tostring(fixedAmount)
else
script.Parent.Text = tostring(newCashAmount)
end
end)