I made a gui shop for buy cash in game [TYCOON] I made 2 test "Buy 500 Cash" and " Buy 1000 Cash" The 1000 works the 500 not
This script going in my TextButtom from my gui; [1000 Cash]
local productId = 22197517
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
This script in starterpack;
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
CASHID = 22197517 -- Put the Developer Product ID here
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
local numberBought = ds:IncrementAsync(playerProductKey, 11)
for i,v in pairs (game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == CASHID then
lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
cs = lds:FindFirstChild("Cash") --Change to your leaderstat
if cs ~= nil then
cs.Value = cs.Value + 1000 --Change to the amount you want this to add
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
This works but when in do the 500 cash [First script the same] Starterpack
local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
CASHID = 22197521 -- Put the Developer Product ID here
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
local numberBought = ds:IncrementAsync(playerProductKey, 1)
for i,v in pairs (game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == CASHID then
lds = v:FindFirstChild("leaderstats")
if lds ~= nil then
cs = lds:FindFirstChild("Cash") --Change to your leaderstat
if cs ~= nil then
cs.Value = cs.Value + 500 --Change to the amount you want this to add
end
end
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
This does not work... And i already did change
local numberBought = ds:IncrementAsync(playerProductKey, 1) --To 11 or 14 (14 is number where product is)
I hope some one can help me Thanks you :)

1 comment
Try just combining the two scripts into one, then putting the one script in the ServerScriptService.