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 4 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)

1plr.CharacterAdded:connect(function(char)
2 
3       if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
4        print("has gamepass)

end end end

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

2 answers

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

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

1game.Players.PlayerAdded:Connect(function(plr)
2    plr.CharacterAdded:Connect(function(char)
3        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, "IDOFGAMEPASS") then
4                print("has gamepass")
5            end
6        end
7    end)
8end)

Hope this helps.

Answer this question