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

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

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

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)

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.

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