How can i check if the player has a gamepass

So im making a double coins gamepass
And i cant find any scripts of checking if a player has a gamepass that works

Can anyone help me?

local MPS=  game:GetService("MarketplaceService")
local passid = 0 -- gamepass id
game.Players.PlayerAdded:Connect(function(plr)
	if MPS:UserOwnsGamePassAsync(plr.UserId, passid) then
		-- do stuff
	end
end)

here

3 Likes

will plr.UserId work or do i need to define it in a local? (like local plr =)

1 Like

the player who joined is passed inside the .PlayerAdded event. So yes, it will work.

1 Like

Oh i didnt see that, thanks!

[characterlimit]