Hello, so I have a dance button and an animation gamepass. I want it so if the user doesn’t own the gamepass it prompts them with a thing to buy it, however if they already own the gamepass it will prompt them with a frame so they can dance.
local gamepassid = 0000000
local marketplace = game:GetService("MarketPlaceService")
local button = -- button
local frame = -- dance frame
button.MouseButton1Click:Connect(function()
if marketplace:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId,gamepassid) then
frame.Visible = true
else
marketplace:PromptGamePassPurchase(game.Players.LocalPlayer,gamepassid)
end
end)
Side note, but you should also listen for when the purchase is completed using PromptGamePassPurchaseFinished
so that the Event will enable the frame without the player having to rejoin for it to work:
local gamepassid = 0000000
local marketplace = game:GetService("MarketPlaceService")
local button = -- button
local frame = -- dance frame
local Player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
if marketplace:UserOwnsGamePassAsync(Player.UserId,gamepassid) then
frame.Visible = true
else
marketplace:PromptGamePassPurchase(Player, gamepassid)
marketplace.PromptGamePassPurchaseFinished:Connect(function(Player, gamepassid, WasPurchased)
if WasPurchased then
frame.Visible = true
end
end)
end
end)
1 Like