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

PlayerHasPass Not Working?

Asked by 9 years ago

Idea Make the textlabel this script is within change based on if they have a specified gamepass.
Problem When I run the code, nothing happens, I own the gamepass as I created it, but it doesn't do anything at all. Any ideas?
Code

-----------------
--| Variables |--
-----------------
local GamePassService = game:GetService('GamePassService')
local PlayersService = game:GetService('Players')
-- Stuffs
local function OnPlayerAdded(player)
    if GamePassService:PlayerHasPass(player, 285663117) then
        script.Parent.Text = "Your In Gold Club"
    end
    end
PlayersService.PlayerAdded:connect(OnPlayerAdded)

Thanks :D

3 answers

Log in to vote
1
Answered by 9 years ago

Simple Solution

Use this code:

-----------------
--| Variables |--
-----------------
local passid = 294320030 -- Gamepass ID
local GamePassService = game:GetService("GamePassService")
-----------------
---|  Stuffs |---
-----------------
game.Players.PlayerAdded:connect(function(player)
repeat wait(0) until player.PlayerGui   
if GamePassService:PlayerHasPass(player, passid) then
player.PlayerGui.ScreenGui.TextLabel.Text = "You're in gold club" --Put where Textlabel is.
else
    player.PlayerGui.ScreenGui.TextLabel.Text = "Normal" --Put where Textlabel is.
end
end)

Next Instead of putting the Script (not a LocalScript) In the TextLabel, put it into Workspace.

Ad
Log in to vote
0
Answered by
duckyo01 120
9 years ago

You need to make a new Instance if you can't just use print.

local GamePassService  =  game:GetService('GamePassService')
local PlayersService  =  game:GetService('Players')
-- Stuffs
game.Players.PlayerAdded:connect(function(player)
    if GamePassService:PlayerHasPass(player, 285663117) then
       script.Parent.Name= "Your In Gold Club"

else
      script.Parent.Name= "Your Not In The Gold Club"

    end
    end)
0
I hope it works duckyo01 120 — 9y
0
Try anonymous functions it may help because it is less confusing. And to make the player to get the gui to popup to say "Your a Gold Member" then you would need to make a seperate script or part. duckyo01 120 — 9y
0
i want to change the text of the scipts parent, not print out anything pluginfactory 463 — 9y
0
Oh ok then go with this I'll edit it but you know gamepass service doesn't work in testing mode. duckyo01 120 — 9y
View all comments (2 more)
0
fixed duckyo01 120 — 9y
0
it still doesnt change for me :/ pluginfactory 463 — 9y
Log in to vote
0
Answered by 9 years ago

I think this is the solution Game:GetService("GamePassService"):PlayerHasPass(player, 285663117)

0
thats the same thing as using the local i added, just this is longer pluginfactory 463 — 9y

Answer this question