Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with my gamepass handler script?? A button should be close

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

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.