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

PlayerHasPass Not Working?

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

✓ Accepted answer

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.

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)

6 comments

0

I hope it works

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.

0

i want to change the text of the scipts parent, not print out anything

0

Oh ok then go with this I'll edit it but you know gamepass service doesn't work in testing mode.

0

fixed

0

it still doesnt change for me :/

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

1 comment

0

thats the same thing as using the local i added, just this is longer

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