Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited by OldPalHappy 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
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.

Ad

Answer this question