UI won't show up after gamepass purchased

I’ve watched a few YouTube videos and put together a script that’s inside of the purchase ImageButton which should prompt a UI once a gamepass is purchased, however it doesn’t seem to work. The purchase works fine however the UI simply does not show up. Any help would be appreciated.

Script inside of purchase button:

local MarketplaceService = game:GetService("MarketplaceService")
local TweenService = game:GetService("TweenService")

local gamepassID = "793726800"
local uiElement = game.Players.LocalPlayer.PlayerGui:WaitForChild("PurchaseUI").ThanksFrame

local function TweenUI()
    uiElement.Position = UDim2.new(0.5, 0, 1.5, 0)
    uiElement.Size = UDim2.new(0, 0, 0, 0)
    uiElement.Visible = true

    local tweenInfo = TweenInfo.new(
        1,
        Enum.EasingStyle.Quad,
        Enum.EasingDirection.Out,
        0,
        false,
        0
    )

    local targetProperties = {
        Position = UDim2.new(0.5, 0, 0.5, 0),
        Size = UDim2.new(0.5, 0, 0.5, 0),
    }

    local tween = TweenService:Create(uiElement, tweenInfo, targetProperties)
    tween:Play()
end

script.Parent.MouseButton1Click:Connect(function()
    MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, gamepassID)
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, assetId, wasPurchased)
    if assetId == gamepassID and wasPurchased then
        TweenUI()
    end
end)

image

1 Like

This is the UI that should appear after the purchase is complete.
image

1 Like

Hello!

With your issue, I would highly suggest using MarketPlaceService.ProcessRecipt = function()

For more information on this function, consider referring to the MarketPlaceService documentation

If you wish, I can provide the code which would suit your needs on this topic.

2 Likes

The gamepass ID variable you’re using stores it as a string. PromptGamePassPurchaseFinished provides the pass ID as a number. That if statement will always fail because they’re different types. Try storing the gamepass ID as a number instead of a string.

@FBIagent9903 ProcessReceipt is for developer products.

2 Likes

Hey there, just checked out the page you sent. I looked through the ProcessReciept function and never knew it existed which is good to know.

I tried implementing it into the script and couldn’t work it out. If I could take you up on that offer on providing the code I’d appreciate that, thanks alot!

1 Like

Will try this out now, thanks.

1 Like

Ah yes! Thank you for identifying this oversight on my behalf. In my entire honesty, I haven’t slept all night and haven’t really fiddled with MarketPlaceService much.

Thanks for identifying my mistake!

1 Like

I think I know how to fix it.

Try using if wasPurchased == true instead of wasPurchased only

Tried this out and it worked, didn’t think it would be so simple, lol.

Anyways thanks alot! This solved it for me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.