When someone purchases gamepass it disables the button and puts a frame over the button so the button is not clickable
Do just that, in your script, when they purchase that gamepass, make a new frame and set its parent to the button, then customize it like making it half transparent or whatever
Maybe you’d find what you need here.
I did that but I still click the button
make a boolean variable to check if the gamepass has already been bought or not and make it so the function only runs if the gamepass is purchased
like this
if gamepasspurchased == true then
-- code for when the button is clicked
end
Try this tutorial - link
This is how I do it, it’s old but it still works
local Script = script
local Button = Script.Parent
local Game = game
local MarketplaceService = Game:GetService("MarketplaceService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local GamePassId = 0 --Change this to the gamepass's ID.
local function OnPromptGamePassPurchaseFinished(Player, Id, Purchased)
if not Purchased then return end
if GamePassId ~= Id then return end
Button.Visible = false --Hide the button (you could instead destroy it if necessary).
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(OnPromptGamePassPurchaseFinished)
local Success, Result = pcall(function() return MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamePassId) end)
if not Success then warn(Result) end
if Result then Button.Visible = false end