Hello,
Here's the script (I know its from the wiki I copied it to make sure there were no mistakes but I have another script that I will use)
local id = 1918309 game.Players.PlayerAdded:connect(function(player) if game:GetService("GamePassService"):PlayerHasPass(player, id) then print(player.Name .. " has the game pass!") else print(player.Name .. " doesn't have the game pass...") end end)
Hi AvionicScript. I don't know why PlayerHasPass has this bug, but it does... Which is why there's a newer and even better way to check if the user has the gamepass!
The new way is UserOwnsGamePassAsync
and is used by doing game:GetService("MarketplaceService"):UserOwnsGamePassAsync(UserId, GamePassId)
The only difference between PlayerHasPass
and UserOwnsGamePassAsync
is that PlayerHasPass caches its result, meaning that it will continue returning the same value even if the user gets the gamepass, while UserOwnsGamePassAsync does not cache its result, making it much better.
I changed your code using this, and it seems to work perfectly fine. The only change is that you use UserId instead of the player's name, which is more reliable anyways.
local id = 1918309 game.Players.PlayerAdded:connect(function(player) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then print(player.Name .. " has the game pass!") else print(player.Name .. " doesn't have the game pass...") end end)