Hello, I am curious on how I would make a thank you ui pop up after someone has purchased a gamepass in-game. Something like the image below. Please keep in mind I am a beginner scripter so try your best to explain in detail and or create a video!
local function gamepassPurchaseFinished(...)
script.Parent.ThankyouFrame.Visible = true
print("PromptGamePassPurchaseFinished", ...)
end
ms.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
So would I replace the 3 dots with my gamepass ID or keep it the same? Because now when I put that, my speed gamepass does not work anymore. Here is my entire code as of now
--{Variables}--
local ScrollingShopFrame = script.Parent.Frame.ScrollingFrame
local ShopButton = script.Parent.Shop
local Click = game.Workspace.GameSounds.Click
local ShopFrame = script.Parent.Frame
local Close = script.Parent.Frame.Exit
--{Open and Close Shop}--
ShopButton.MouseButton1Down:Connect(function()
Click:Play()
ShopFrame.Visible = true
ShopFrame:TweenPosition(UDim2.new(0.26, 0,0.183, 0))
end)
Close.MouseButton1Down:Connect(function()
Click:Play()
ShopFrame.Visible = true
ShopFrame:TweenPosition(UDim2.new(0.26, 0,1.183, 0))
end)
--{Purchase Gamepasses}--
local ms = game:GetService("MarketplaceService")
local DoubleCashID = 12976761
local BoomboxID = 12977194
local DoubleSpeedID = 12977366
--{Double Cash}--
script.Parent.Frame.ScrollingFrame.Gamepass1.Purchase.MouseButton1Down:Connect(function()
ms:PromptGamePassPurchase(game.Players.LocalPlayer, DoubleCashID)
Click:Play()
end)
--{Boombox}--
script.Parent.Frame.ScrollingFrame.Gamepass2.Purchase.MouseButton1Down:Connect(function()
ms:PromptGamePassPurchase(game.Players.LocalPlayer, BoomboxID)
Click:Play()
end)
--{Double Speed}--
script.Parent.Frame.ScrollingFrame.Gamepass3.Purchase.MouseButton1Down:Connect(function()
ms:PromptGamePassPurchase(game.Players.LocalPlayer, DoubleSpeedID)
Click:Play()
end)
local function gamepassPurchaseFinished(...)
script.Parent.ThankyouFrame.Visible = true
print("PromptGamePassPurchaseFinished", ...)
end
ms.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
For the last part, you need to check that the local player was the one who bought the pass, as this function fires whenever anyone buys a gamepass (i think, dont quote me on this). You also need to check if the gamepass was purchased and to check that it is the correct gamepass.
ms.PromptGamePassPurchaseFinished:Connect(function(plr, passId, purchased)
if plr == game.Players.LocalPlayer and passId == 'insertgamepassidherebutasanumbernotastring' and purchased then
-- do stuff
end
end)
this should be pretty self explanatory. Let me know if you are still stuck. Please mark as solution if this helped you, as Iād like more people to be able to see this.