Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to have text Gui appear after purchase??

Asked by 1 year ago

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)

0
on line 12 maybe try putting a repeat wait() until Enum.ProductPurchaseDecision.PurchasedGranted == true instead of the if loop? manith513 121 — 1y
0
alr i will try that thx theking66hayday 841 — 1y
0
Sadly it didn't work theking66hayday 841 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
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)
0
I'll try this theking66hayday 841 — 1y
0
It doesn't display the text still theking66hayday 841 — 1y
0
Did you checked the output for any errors? santi_luly1 47 — 1y
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 theking66hayday 841 — 1y
View all comments (3 more)
0
But if i remove then end on line 12 it comes up with errors theking66hayday 841 — 1y
0
try on line 9 "if purchased and id == productId then" santi_luly1 47 — 1y
0
ok theking66hayday 841 — 1y
Ad

Answer this question