So I have this gamepass in my game… of the ID 837859114.
And this script, which is supposedly meant to check if I own the gamepass or not.
function isAuthenticated(player)
return game:GetService("GamePassService"):PlayerHasPass(player, 837859114)
end
-- Code in game.Players.PlayerAdded function.
if isAuthenticated(player) == true then
print("has pass")
else
print("doesn't have pass")
end
And, once I owned the gamepass, it did print “has pass”, I then tried to see if it would work if I didn’t own it. So I deleted it from my inventory, and tested it. It was still printing “has pass”.
Is this a bug or am I doing something wrong?
Also, it all used to work back when :PlayerHasPass() wasn’t a thing.
You’re discovering the downsides of PlayerHasPass caching. On its Wiki page, it explains a little bit what this means:
Once you call PlayerHasPass on a certain gamepass, it will always return the same value as the first call. This has been brought up before on the gamepass change announcement thread. There have been no public notifications that this will be changed as far as I’m aware.
I see… but doesn’t that mean if player1 joins, owns it - player2 joins, and it also says that he/she owns it too?
How else could I use :PlayerHasPass()
It caches per player per gamepass, so if another player joins and you check the result of the same gamepass, it won’t be cached. Once you check ownership of a gamepass for a player though, checking the ownership of that same gamepass and same player will always return the result you got the first time. For now, just ignore the warnings and use PlayerOwnsAsset.
Can we get an update on this? I get at least 5 complaints about this a day now because they keep trying to rejoin their friends and end up losing the weapons they bought in that server