The TextButton Modal Don't Change When Player Make A Purchase

Hi im a new scripter
I made this script so when a player click the button show the purchase ui and make the modal true, but i don’t know how to disable the modal when the player cancel/purchase the dev product.

script.Parent.MouseButton1Click:Connect(function(player, assetID, isPurchased)
	local Mp = game:GetService("MarketplaceService")
	Mp:PromptProductPurchase(game.Players.LocalPlayer, 1326536385)
	script.Parent.Modal = true
		script.Parent.Modal = false

Anyone know how to do that?

Hello, try looking at PromptProductPurchaseFinished in the Roblox documentation. It’s deprecated signal, however it’s the only way how to detect that player cancelled or bought a developer product.

However, keep in mind, that if you want to process a purchase, you must set a callback to ProcessReceipt on server side.