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

How do I check to see if someone has my gamepass in game, to give them abilities?

Would it be similar to this? Because this isn't working.

local id = 5348469
 
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)

1 answer

✓ Accepted answer

###Gamepass Changes

A while ago, roblox changed how they handle gamepasses. They now have them as seperate assets. This caused a url change ("https://roblox.com/game-pass/id") aswell as the change in gamepass-fetching methods.

PlayerHasPass is broken and no longer in use. Instead, opt to use the new method UserOwnsGamePassAsync. Additonally, it now take's a players UserId, not the player object themselves.

###Solution

local id = 5348469

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)

4 comments

0

please use code blocks

0

I'll try it, and by the way, you didn't put code blocks between your code.

0

speed demon answer

0

Ty, it worked.

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