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

GamePassService is not working properly?

So, i'm trying to make it so that If a player has a gamepass, a button(s) appears.

This gamepass gives you 1 weapon when bought:

local passid = 170543256
local GamePassService = Game:GetService('GamePassService')
if GamePassService:PlayerHasPass(player, passid) then
	script.Parent.Parent.Parent.Parent.MainFrame.Row1.KNIFEGUN.Visible = true
end

This gamepass gives you 2 weapons when bought:

local passid =  170544124
local GamePassService = Game:GetService('GamePassService')
if GamePassService:PlayerHasPass(player, passid) then
	script.Parent.Parent.Parent.Parent.MainFrame.Row1.M37.Visible = true
	script.Parent.Parent.Parent.Parent.MainFrame.Row1.m.Visible = true
end


This is not in a LocalScript.

2 comments

0

Where is player defined? Is there more to the script?

0

On a separate script i didnt upload to this site, I did difine player, but still no luck

1 answer

Your issue is that "player" isn't defined, and there is no event that calls this.

local id = 170543256
local gps = game:GetService("GamePassService")

game.Players.ChildAdded:connect(function(p)
if gps:PlayerHasPass(p, id) then
script.Parent.Parent.Parent.Parent.MainFrame.Row1.KNIFEGUN.Visible = true
end
end)

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