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

01-----------------
02--| Variables |--
03-----------------
04local GamePassService = game:GetService('GamePassService')
05local PlayersService = game:GetService('Players')
06-- Stuffs
07local function OnPlayerAdded(player)
08    if GamePassService:PlayerHasPass(player, 285663117) then
09        script.Parent.Text = "Your In Gold Club"
10    end
11    end
12PlayersService.PlayerAdded:connect(OnPlayerAdded)

Thanks :D

3 answers

Log in to vote
1
Answered by 9 years ago

Simple Solution

Use this code:

01-----------------
02--| Variables |--
03-----------------
04local passid = 294320030 -- Gamepass ID
05local GamePassService = game:GetService("GamePassService")
06-----------------
07---|  Stuffs |---
08-----------------
09game.Players.PlayerAdded:connect(function(player)
10repeat wait(0) until player.PlayerGui  
11if GamePassService:PlayerHasPass(player, passid) then
12player.PlayerGui.ScreenGui.TextLabel.Text = "You're in gold club" --Put where Textlabel is.
13else
14    player.PlayerGui.ScreenGui.TextLabel.Text = "Normal" --Put where Textlabel is.
15end
16end)

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.

01local GamePassService  =  game:GetService('GamePassService')
02local PlayersService  =  game:GetService('Players')
03-- Stuffs
04game.Players.PlayerAdded:connect(function(player)
05    if GamePassService:PlayerHasPass(player, 285663117) then
06       script.Parent.Name= "Your In Gold Club"
07 
08else
09      script.Parent.Name= "Your Not In The Gold Club"
10 
11    end
12    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