I'm new to developer products and stuff. I made a developer product that gives the user ingame currency. The script works, but the user gets the currency before you press "buy". In the wiki it tells me to use datastores to keep track of who bought the developer product, why would that be necessary?
Script:
script.Parent.MouseButton1Click:connect(function() local Market = game:GetService("MarketplaceService") local id = 23747241 -- the Developer Product ID Market:PromptProductPurchase(game.Players.LocalPlayer, id) print("Bought") game.Players.LocalPlayer.Clashbux.Value = game.Players.LocalPlayer.Clashbux.Value + 5000 end)
productId = 0 -- change to your id script.Parent.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) end) local MarketplaceService = Game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") MarketplaceService.ProcessReceipt = function(receiptInfo) -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == productId then -- I'm guessing Clashbux is in leaderstats player.leaderstats.Clashbux.Value = player.leaderstats.Clashbux.Value + 5000 end end end local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
KEY POINTS: receiptinfo records the purchase after receipt is processed you are able to put your next move under it the last part tells server that you handled the purchase with any other questions ask me