How do you make a textbutton that only works if you have a certain gamepass?

So, this is my second post in this category. (I really need a lot of help in this category I guess :slight_smile:)

Basically, I am making this game (once more time is put into it I will link the game here) and for one of my monetization strategies I need to make a textbutton that only unlocks more content of the game only if you have a certain gamepass. How do I do this?!

I have tried searching in Google “how to make a gamepass only textbutton roblox studio” but that only showed up tutorials on how to make a textbutton that pops up a gamepass. If you are about to ask me if I looked it up in the wiki, don’t. In the search results of Google Chrome, tutorials from the wiki also show up in the search results.

Thanks in advance for any help I may get.

Add this local script to the textbutton:
Then add the script that unlocks the other things in an another local script.

local MS = game:GetService("MarketplaceService")
local gamepassid = 0
if MS:UserOwnsGamePassAsync(game.Players.LocalPlayer.userId, gamepassid) == false then

script.Parent:Destroy()

end
2 Likes

This will basically remove the textbutton if the player dosen’t own the gamepass.

Ok, thanks for the help! :grinning:

Uh, no, don’t do that. Exploiters and such can still access your content before your script has a chance to function. Depending on what the TextButton needs to do, either the server should be replicating a UI or blocking functionality on it’s end.

2 Likes