Hello, I am new to Developer Products, so please don't call me a "Noob" I need help with this script, where when somebody is prompted to purchase it in another script, this one fires, then gives the player coins. However, none of this happens, so the Player only wastes ROBUX. Here is the ServerScript:
local MarketplaceService = game:GetService("MarketplaceService") local IdOne, IdTwo, IdThree, IdFour, IdFive, IdSix = 98320218, 98320249, 98321378, 98321410, 98324883, 98325157 local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") function MarketplaceService.ProcessReceipt(receiptInfo) local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync(playerProductKey) then return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it. end -- find the player based on the PlayerId in receiptInfo local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId) if not player then -- Seems like we can't find the player... already left? return Enum.ProductPurchaseDecision.NotProcessedYet -- Can't process end if receiptInfo.ProductId == IdOne then player.Stats.Coins.Value = player.Stats.Coins.Value + 10 elseif receiptInfo.ProductId == IdTwo then player.Stats.Coins.Value = player.Stats.Coins.Value + 25 elseif receiptInfo.ProductId == IdThree then player.Stats.Coins.Value = player.Stats.Coins.Value + 150 elseif receiptInfo.ProductId == IdFour then player.Stats.Coins.Value = player.Stats.Coins.Value + 500 elseif receiptInfo.ProductId == IdFive then player.Stats.Coins.Value = player.Stats.Coins.Value + 1500 elseif receiptInfo.ProductId == IdSix then player.Stats.Coins.Value = player.Stats.Coins.Value + 6000 end -- record the transaction in a Data Store PurchaseHistory:SetAsync(playerProductKey, true) -- tell ROBLOX that we have successfully handled the transaction (required) return Enum.ProductPurchaseDecision.PurchaseGranted end
Refer to this ROBLOX Wiki article here. This should help you a lot. Please accept my answer if this helped!