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
@lordmochibi and @TheFurryFish appreciate the answers, this completely contradicts the solution to this other devforum post and so I did not try using that.
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).
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.