Everything works but PromptPurchaseFinished, the Marketplace charges me but it doesn't fire the event that stores and gives the item.
local PurchaseEvent = game.ReplicatedStorage.PurchaseEvent local MarketplaceService = game:GetService("MarketplaceService") local History = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local PlayerInventory = game:GetService("DataStoreService"):GetDataStore("PlayerInventory") local C5 = 25816199 local C10 = 25855812 local C15 = 25855821 PurchaseEvent.OnServerEvent:connect(function(Player,Item, Price) local TotalPrice print(Player.Name) print(Item) print(Price) if Price == 5 then TotalPrice = C5 elseif Price == 10 then TotalPrice = C10 elseif Price == 15 then TotalPrice = C15 end print(C5.." "..C10.." ".. C10) print(TotalPrice) MarketplaceService:PromptProductPurchase(Player, TotalPrice) end) MarketplaceService.PromptPurchaseFinished:connect(function(Player, ItemID, Purchased) print("Purchase finished") if Purchased then local wantedItem = Player.PlayerGui.CAStore.ItemCart.Value local clonedItem = game.ServerStorage.wantedItem:Clone() clonedItem.Parent = Player.Backpack MarketplaceService.ProcessReceipt = function(receiptInfo, Player) local DataToBeSaved = receiptInfo.PlayerId.. " bought " .. receiptInfo.ProductId .. " by " .. receiptInfo.CurrencySpent .. "." print(DataToBeSaved) if Player.userId == receiptInfo.PlayerId then History:IncrementAsync(DataToBeSaved, 1) PlayerInventory:IncrementAsync(Player.PlayerGui.CAStore.ItemCart.Value, 1) end return Enum.ProductPurchaseDecision.PurchaseGranted end end end)
I think your script is failing because of poor indentation resulting in "end"s in the wrong spot. Your "ProcessReceipt" function should be outside all other functions, or else it can't be run until a successful purchase has occurred (which can't happen until that function is run).
I expect that you got (or will get) your money back at some point (at least, I hope that's how it works, unless you have another script elsewhere with ProcessReceipt that always returns "PurchaseGranted" -- but you're only supposed to have one ProcessReceipt function).