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)
