My script gets triggered even if you don't buy the product

Hello So Im making a dev product and when I click cancel on the buy thing it triggers the print command but it is only work if you the product

the script is down below​:point_down::point_down:

script.Parent.MouseButton1Click:connect(function()
game:GetService(“MarketplaceService”):PromptProductPurchase(game.Players.LocalPlayer, 1805041559)
end)

game:GetService(“MarketplaceService”).ProcessReceipt:Connect(function()
print(“Works!”)
end)

you might wanna use PromptProductPurchaseFinished

1 Like

I put together a script of what @yoshicoolTV was talking about. Hopefully this helps!

local player = game:GetService("Players").LocalPlayer
local gamepassID = 773469509

script.Parent.MouseButton1Click:connect(function()
	if marketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID) then
		print("Has already bought GamePass")
	else
		marketplaceService:PromptGamePassPurchase(player, gamepassID)
	end
end)

marketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassPurchasID, wasPurchased)
	if gamepassID == gamePassPurchasID and wasPurchased then
		print("Just barley Purchased")
	end
end)

ProcessReceipt isn’t an event, it’s a callback, meaning you have to assign it a function to properly function.

Service.ProcessReceipt = Callback;

PromptProductPurchaseFinished fires everytime you close the prompt, it is also not intended to be used instead of ProcessReceipt

I want it to be a developer product