I know that the button is located at the NPC's head and its dialog and its shop (ScreenGui) and its frame that has button that i need to close after a player has bought the gamepass. Here is the script.
local passid = 1422734652 -- The ID of the gamepass goes here local GamePassService = game:GetService('GamePassService') local PlayerName = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui") local ButtonToBeClose = PlayerName.Shop3.Frame:WaitForChild("GamepassPurchase") local player = game:GetService("Players").LocalPlayer if GamePassService:PlayerHasPass(player, passid) then ButtonToBeClose.Visible = false end
GamePassService:PlayerHasPass()
Is a cached value, the server saves whether the player has the pass and this value will be the same as when they joined regardless if the player gets the pass while they're in the game.