How can i detect if player has gamepass? (not LocalPlayer)

I want to detect if player has gamepass. (I’m making gamepass gift system)
I’m using marketPlaceService:UserOwnsGamepassAsync (In local script)

i tried to detect other players but it doesnt work with an error “UserOwnsGamePass can be only called with localplayer”.

Everything works well except this problem.

Sample code :

local mps = game:GetService("MarketPlaceService")
if mps:UserOwnsGamePassAsync(playerID, gamepassID) == true then
print(true)
else
print(false)
end

You are doing it in local or server script? And please show full script

1 Like

See this line
I’m using marketPlaceService:UserOwnsGamepassAsync (In local script)

:UserOwnsGamepassAsync() only accepts one player’s userid at a time. Plus I’m pretty sure you can use this in a serverscript:

Players.PlayerAdded:Connect(function(Player)
    if MarketPlaceService:UserOwnsGamepassAsync(Player.UserId, GamepassID) then
       ...
    end
end)
1 Like

As AustinBlox said, you need PlayerID

1 Like

I can use marketPlaceService in server script service?

2 Likes

Ye you need 1 player id and it has to be in a server script

2 Likes

Yes. You can use it in serverscriptservice.

1 Like

Oh, then i will try it in server script service using fireserver.
Thanks very much

1 Like

You wouldn’t need to use any remote events because this is checking if the local player has the gamepass through a server-script.

Hope the code I have displayed helps.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.