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

GamePassService is not working properly?

Asked by 10 years ago

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.

0
Where is `player` defined? Is there more to the script? BlueTaslem 18071 — 10y
0
On a separate script i didnt upload to this site, I did difine player, but still no luck PyccknnXakep 1225 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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)
Ad

Answer this question