MarketPlaceService PlayerOwnsAsset incorrectly returning false

Hello, within a playeradded script I am using the following snippet:

if player.Name == "TomsGames" then
	print("Manual checks for TomsGames")
	print("Does TomsGames own 9867672, GPEYes?")
	print(ms:PlayerOwnsAsset(player, 9867672))
	print("Does TomsGames own 9867678, GPLight?")
	print(ms:PlayerOwnsAsset(player, 9867678))
end

image

However I own both of these gamepasses.

I have no explanation as to why this is not working, it must be something on my end. What am I missing?

There is a function named MarketplaceService:UserOwnsGamePassAsync(). Have you tried using that?

The arguments for them are the player’s user ID, and the game pass ID.

Example:

print(MarketplaceService:UserOwnsGamePassAsync(player_id, gamepass_id))
2 Likes

This is occurring because the asset you’re referring to is a gamepass, as @RedApplePair33 suggested, you must use UserOwnsGamePassAsync instead.

@RedApplePair33 and @TheFurryFish appreciate the answers, this completely contradicts the solution to this other devforum post and so I did not try using that.

I’ll use that and mark a solution if it works.

UserOwnsGamePassAsync is built exactly for this kind of thing so you should use it instead of PlayerOwnsAsset. It’s simple as

local marketplaceService = game:GetService("MarketplaceService")
local gamePassID = 000000

game.Players.PlayerAdded:Connect(function(player)
    if marketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) then
       print(player.Name.." owns the game pass!")
    end
end)

Just make sure you’re using the right tool for the job. I can’t really say anything about PlayerOwnsAsset because UserOwnsGamePassAsync was built for this exact purpose so it is recommended that you use that instead of PlayerOwnsAsset. At least just try it and see if it works. The point made in that post is that there isn’t really a difference between them but I don’t think Roblox would make the UserOwnsGamePassAsync for no reason(hopefully).

1 Like

Also, try posting the entire script. The call to the library may not actually be the problem; it may be some other code that is the issue.

I just tested PlayerOwnsAsset on several gamepass IDs that I own and none of them returned true. In April of 2018, gamepasses were assigned a new ID system, which made them incompatible with other asset-related functions like PlayerOwnsAsset.

2 Likes