Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont the .PromtpPurchaseFinished function fire after the purchase is complete?

I am trying to make the script print "done" when the purchase is done, just for testing purposes. I even tested the script live in a real game and still didn't print anything after the purchase was complete. Why? It shows no errors...

The Code

local Market = game:GetService('MarketplaceService')
local Ticket = 36931483

script.Parent.Touched:connect(function(plr)
	if plr.Parent:FindFirstChild('Humanoid') ~= nil then
		local player = game.Players:GetPlayerFromCharacter(plr.Parent)
		Market:PromptProductPurchase(player, Ticket)
	else
		--nothing
	end
end)

Market.PromptPurchaseFinished:connect(function(player, Ticket, isPurchased)
	print('done')
	print(isPurchased)
end)

1 answer

I have tested this and I have come up with this.

Firstly make a new script, not a local script, a normal script. Then drag the new script into the part that you want to prompt the purchase (aka a button or a plate because it uses Touched because I know you are using this for a circus/something that uses a raffle ticket. Now this will work! Paste this code into the script:

local Market = game:GetService("MarketplaceService")
local Ticket = 36931483
deb = false

script.Parent.Touched:connect(function(plr)
    if plr.Parent:FindFirstChild('Humanoid') ~= nil then
	if deb == false then
		deb = true
        local player = game.Players:GetPlayerFromCharacter(plr.Parent)
        Market:PromptProductPurchase(player, Ticket)
script.Parent.BrickColor = BrickColor.new("Bright red")
        print("Done")
        print("It will not define/print in the function below so you cannot print isPurchased. Sorry")
wait(1) -- or a custom time
script.Parent.BrickColor = BrickColor.new("Bright green")
deb = false
    else
        -- Nothing To Do!
end
    end
end)

Market.PromptPurchaseFinished:connect(function(player, Ticket, isPurchased)
end)

Thank you!

Kind Regards,

TheUniPiggy

PS: You have to wait a while sometimes/test it a few times till it works.

If you have any trouble or need it fixing, please comment below or message me via roblox. Thank you for your time.

1 comment

0

Why am I -2? Its correct.

This discussion is preserved as it was. New answers, comments, and votes are closed.