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 | ----------------- |
04 | local GamePassService = game:GetService( 'GamePassService' ) |
05 | local PlayersService = game:GetService( 'Players' ) |
06 | -- Stuffs |
07 | local function OnPlayerAdded(player) |
08 | if GamePassService:PlayerHasPass(player, 285663117 ) then |
09 | script.Parent.Text = "Your In Gold Club" |
10 | end |
11 | end |
12 | PlayersService.PlayerAdded:connect(OnPlayerAdded) |
Thanks :D
Simple Solution
Use this code:
01 | ----------------- |
02 | --| Variables |-- |
03 | ----------------- |
04 | local passid = 294320030 -- Gamepass ID |
05 | local GamePassService = game:GetService( "GamePassService" ) |
06 | ----------------- |
07 | ---| Stuffs |--- |
08 | ----------------- |
09 | game.Players.PlayerAdded:connect( function (player) |
10 | repeat wait( 0 ) until player.PlayerGui |
11 | if GamePassService:PlayerHasPass(player, passid) then |
12 | player.PlayerGui.ScreenGui.TextLabel.Text = "You're in gold club" --Put where Textlabel is. |
13 | else |
14 | player.PlayerGui.ScreenGui.TextLabel.Text = "Normal" --Put where Textlabel is. |
15 | end |
16 | end ) |
Next Instead of putting the Script (not a LocalScript) In the TextLabel, put it into Workspace.
You need to make a new Instance if you can't just use print.
01 | local GamePassService = game:GetService( 'GamePassService' ) |
02 | local PlayersService = game:GetService( 'Players' ) |
03 | -- Stuffs |
04 | game.Players.PlayerAdded:connect( function (player) |
05 | if GamePassService:PlayerHasPass(player, 285663117 ) then |
06 | script.Parent.Name = "Your In Gold Club" |
07 |
08 | else |
09 | script.Parent.Name = "Your Not In The Gold Club" |
10 |
11 | end |
12 | end ) |
I think this is the solution Game:GetService("GamePassService"):PlayerHasPass(player, 285663117)