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

how do I check if someone has a gamepass when they join?

Asked by 3 years ago

this is basically what I have dumbed down. is there a better way to do this? it works for only my account and doesn't work for other accounts

`~~~~~~~~~~~~~~~~~ game.Players.PlayerAdded:Connect(function(plr)

plr.CharacterAdded:connect(function(char)

       if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
        print("has gamepass)

end end end

~~~~~~~~~~~~~~~~~ `

2 answers

Log in to vote
0
Answered by 3 years ago
local GamepassID = 0 --- id
game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserID, GamepassID) then
        print("Player owns gamepass.")
    end
end)
Ad
Log in to vote
0
Answered by 3 years ago

Instead of game.Playersid, it should be (plr.UserId, "IDOFGAMEPASS"). This is the correct code:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, "IDOFGAMEPASS") then
                print("has gamepass")
            end
        end
    end)
end)

Hope this helps.

Answer this question