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

How to have text Gui appear after purchase??

Hi, I am having issues getting my Gui text to appear after a player purchases the product. What keeps happening is that as soon as the player clicks the button it comes up I want it to come up when the player has purchased the product. local script in Gui button:

local MarketPlaceService = game:GetService("MarketplaceService")

local productId = 1333302500 -- Id

local player = game.Players.LocalPlayer


script.Parent.MouseButton1Click:connect(function()

    MarketPlaceService:PromptProductPurchase(player, productId)

    if Enum.ProductPurchaseDecision.PurchaseGranted then

        script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Visible = true

        script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Text = "Thank you for your purchase: " ..player.Name

        wait(6)

        script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Visible = false

    end

end)

3 comments

0

on line 12 maybe try putting a repeat wait() until Enum.ProductPurchaseDecision.PurchasedGranted == true instead of the if loop?

0

alr i will try that thx

0

Sadly it didn't work

1 answer

local MarketPlaceService = game:GetService("MarketplaceService")
local productId = 1333302500 -- Id
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	MarketPlaceService:PromptProductPurchase(player, productId)

	MarketPlaceService.PromptPurchaseFinished:Connect(function(p, id, purchased)
		if purchased then
			delay(6, function() --It's the same as wait() :D
				script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Visible = false
			end)
			script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Visible = true
			script.Parent.Parent.Parent.Parent.Special.Thankyoucommand.Text = "Thank you for your purchase: " ..player.Name
		end
	end)
end)

7 comments

0

I'll try this

0

It doesn't display the text still

0

Did you checked the output for any errors?

0

I did not any errors issue is on the script is that end) ended the script and will not do the textlable appearing and disappearing

0

But if i remove then end on line 12 it comes up with errors

0

try on line 9 "if purchased and id == productId then"

0

ok

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