isPurchased Issues

  1. What do you want to achieve?
    I want to be able to reward users for their purchases.
  2. What is the issue?
    The function “MarketplaceService.PromptPurchaseFinished:Connect(function(Buyer, productID, isPurchased)” is not executing after a purchase.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have rewritten it several times and will not work. I had gotten the fuction from the developer wiki and tried multipule times.
local MarketplaceService = game:GetService("MarketplaceService")
local HttpServ = game:GetService("HttpService")
local WebUrl = "private"
local Events = game:GetService("ReplicatedStorage")

function PromptBuyer()
	print("Prompting!")
	MarketplaceService:PromptProductPurchase(Buyer,productID)
	print(Buyer, productID, isPurchased)
end


MarketplaceService.PromptPurchaseFinished:Connect(function(Buyer, productID, isPurchased)

if isPurchased then
	print("Purchased!")
Buyer.PlayerData.Diamonds.Value = Buyer.PlayerData.Diamonds.Value + PurchaseAmount
local data = 
{
content = "**[Buyer:]** "..Buyer.." **[Diamonds Bought:]** "..PurchaseAmount;
username = "PurchaseLog";
}
HttpServ:PostAsync(WebUrl, HttpServ:JSONEncode(data))
	else
	print("Exited")
end
end)





Events.Purchases.OnServerEvent:Connect(function(Player,Serial)
	Buyer = Player
	if Serial == "p5" and Buyer.MembershipType == Enum.MembershipType.Premium then
		 productID = 963023584
		PurchaseAmount = 5
		PromptBuyer()
	elseif Serial == "p10" and Buyer.MembershipType == Enum.MembershipType.Premium then
		productID = 963023472
		PurchaseAmount = 10
		PromptBuyer()
	elseif Serial == "p25" and Buyer.MembershipType == Enum.MembershipType.Premium then
		productID =	963023436
		PurchaseAmount = 25
		PromptBuyer()
	elseif Serial == "p50" and Buyer.MembershipType == Enum.MembershipType.Premium then
		productID =	963023610
		PurchaseAmount = 50
		PromptBuyer()
	elseif Serial == "p100" and Buyer.MembershipType == Enum.MembershipType.Premium then
		productID =	963023661
		PurchaseAmount = 100
		PromptBuyer()
	elseif Serial == "p200" and Buyer.MembershipType == Enum.MembershipType.Premium then
		productID = 963023698
		PurchaseAmount = 200
		PromptBuyer()
		PurchaseAmount = 1
	elseif Serial == "5" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	elseif Serial == "10" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	elseif Serial == "25" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	elseif Serial == "50" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	elseif Serial == "100" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	elseif Serial == "200" then
		productID = 1
		PurchaseAmount = 1
		PromptBuyer()
	else
		print("Invalid Product!")
	end 
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Easy Way to Make it:
First. Put the LOCAL script below in text button or any button

local Player = game.Players.LocalPlayer
local Id = 1608615895

script.Parent.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(Player,Id)
end)

And then
Put the script below in ServerScriptService:

local Id = 1608615895
local StatName = "Gold"
local Increase = 5
-- If u want to do more than one:
local Id2 = 1608616541
local Increase2 = 40

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local productFunctions = {}

productFunctions[Id] = function(receipt, player)
	local stats = player:FindFirstChild("leaderstats")
	local gold = stats and stats:FindFirstChild(StatName)

	if gold then
		gold.Value = gold.Value + Increase
		return true
	end
end

-- Here too:
productFunctions[Id2] = function(receipt, player)
	local stats = player:FindFirstChild("leaderstats")
	local gold = stats and stats:FindFirstChild(StatName)

	if gold then
		gold.Value = gold.Value + Increase2
		return true
	end
end

local function processReceipt(receiptInfo)
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if player then
		local handler = productFunctions[productId]
		local success, result = pcall(handler, receiptInfo, player)
		if success then
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Failed to process receipt:", receiptInfo, result)
		end
	end
	return Enum.ProductPurchaseDecision.NotProcessedYet
end

MarketplaceService.ProcessReceipt = processReceipt