BadgeService:UserHasBadge behavior change - request

I don’t usually use BadgeService, but today when checking up on the UserHasBadge method, I noticed something strange

Originally, this method did not explicitly require the player to be present in the game.
The reason this method is still useful even today, is that you can check if a given user owns an asset without them being present in the game - which was the case up until now.

It would be nice if the behavior could be changed back, so this method is still of use in some cases (such as checking if a game creator owns a given model before proceeding with some code)

9 Likes

You can also use this:

game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, AssetId)
1 Like

As mentioned in the post, UserHasBadge does not require a Player instance, which was what made it useful for when the player was not present in the game, but you knew their user ID.

This method has behaved this way since at least 2012.

What are your use cases for this? What are your use cases for this? If you want to check if the game creator owns a model, you should be using PlayerOwnsAsset like @Nitefal mentions.

That’s not true. It has not been this way since 2012. For as long as I’ve remembered I’ve used :UserHasBadge because in the 2014/2015 era, PlayerOwnsAsset cached which made it impractical, I never really broke the habit of using :UserHasBadge.

As the OP mentioned this method is not the same as PlayerOwnsAsset because PlayerOwnsAsset absolutely requires the Player instance. Perhaps a solution to this would be to allow PlayerOwnsAsset to accept both Player instance, and a UserID.

I’m still interested in use cases for checking ownership on behalf of a player who isn’t in the game.

One example I can give is my admin gui in my games, it allows me to enter a username, or a userid, and then load their data, and change it. this allows me to quickly erase people who cheat/exploit to get to the top of the leaderboards.

The admin gui displays all the gamepasses and badges, with a checkmark if they own it.

I also had a project a while back which used UserHasBadge because you could click players on the leaderboard and view their stats, which also showed their gamepasses because gamepasses can influence how quickly they got their high stats.

This is my particular use case, although insignificant I still don’t see why UserHasBadge must require the player to be in the game.

1 Like

The use case from OP was because I was helping a guy who needed to check if the owner of some arbitary game owned his seat model.
While his intended idea of just removing the model if it got leaked to people who do not own his model, which of course can be bypassed if the person that ended up with the model found and changed the source code, the problematic in this client bug is that it is not possible to do what this guy wants to do, but it was in the past.