Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
green271 635 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
please use code blocks theking48989987 2147 — 5y
0
I'll try it, and by the way, you didn't put code blocks between your code. protectiverobos -50 — 5y
0
speed demon answer SummerEquinox 643 — 5y
0
Ty, it worked. protectiverobos -50 — 5y
Ad

Answer this question