Currently I am making a plugin and I need to check whether the logged in user (StudioService:GetUserId()) owns a certain asset or not.
I’ve encountered a roadblock with the MarketplaceService:PlayerOwnsAsset() function, which would be ideal if it took a UserId, however it requires a Player Instance, which might or might not be available in Edit mode.
Any ideas or workarounds on how to check whether the local user owns an asset inside a plugin, ideally with the user’s Id and ideally without HttpService?
Not sure if the info I’m giving out here is fully correct, but:
There is a player instance under Players only when you’re connected to a Team Create editing session or whatever it is called nowadays, even if session is empty. Solo editing sessions don’t create those player instances.
This is why I’ve said:
However, I’ve found a pretty decent workaround to this limitation, you can just call game:GetObjects() in a protected call and check if the call errors out or not.
If it does, that most likely means that the user either doesn’t own that asset, there is a network issue or the asset type is not supported by :GetObjects()
So if anybody else runs into this issue, you could just use :GetObjects() as a workaround;
Note that this doesn’t necessarily confirm asset ownership, but yet again, that depends on the asset you’re checking on. ALSO, make sure to handle different outcomes appropriately.