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)
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.
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!
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.