I'm honestly clueless on what to do. Basically I have a gamepass and when the user purchases it they have something they can do. In the end, I want the script to run and when they join the game if the player has the gamepass I want it to turn a textbutton visibility to true (Does not matter what the name of the gui is). I checked the wiki but there example just seemed to confusing for me. Maybe if someone could explain it a little more and show me how to do it I might get a better understanding. Thanks!
local GamePassService = game:GetService("GamePassService")
local GamePassId = 185260715
game.Players.PlayerAdded:connect(function(player)
if GamePassService:PlayerHasPass(player, GamePassId) then
print("Username: " ..player " got dat pass")
game.Players[player].PlayerGui.MenuGUI.Menu.twoDoff.Visible = true
end
end)

5 comments
This is a script, should it be a localscript?
Whoops I see now, thanks lol my mistake.
It should be a server Script in Workspace or ServerScriptService. PlayerAdded events don't work well in LocalScripts, but we could edit the code to work correctly in LocalScripts if needed.
So what example would you use? The last one you wrote Perci? And also what line would you insert it into?
WaitForChild() delays the script until the child exists, then returns that child. You can therefore use it directly, e.g. 'player:WaitForChild("PlayerGui").Gui:Destroy()' . I use WaitForChild() a lot when scripting for it helps prevent errors due to lag.