Making a model appear in a different state when the player hasn't unlocked it

How do I make it so that the model on the right appears instead of the model on the left when a player hasn’t unlocked a certain badge? Any help would be greatly appreciated!

hat_models.rbxm (7.8 KB)

use BadgeService:UserOwnsBadge()

1 Like


On the client:

local player = game.Players.LocalPlayer
local userHasBadgeFunc = ... -- whatever the remote function is

local BADGE_ID = 000000 -- change for badge id

local ownsBadge = userHasBadgeFunc:InvokeServer(BADGE_ID)

if ownsBadge then
    print(player, "has the badge")
	-- Make hat visible
    print(player, "does not have the badge")
	-- Make hat ghost effect / whatever you're doing

On the server:

local BadgeService = game:GetService("BadgeService")
local func = ... -- Whatever the remote function is

func.OnServerInvoke = function(player, badgeId)
	return BadgeService:UserHasBadgeAsync(player.UserId, badgeId)

(UserOwnsBadge is now deprected)


To add to this, UserHasBadge still works and can be used to avoid communicating with the server through the RemoteFunction:

local BadgeService = game:GetService("BadgeService") 
local Players = game:GetService("Players")

local Player = Players.LocalPlayer 

local BadgeId = 0 --your badge id 

--not using async
local OwnsBadge = BadgeService:UserHasBadge(Player.UserId, BadgeId)

1 Like

Considering it’s deprecated status I would advise against using it as its functionality could be removed at any given moment which would result in the script breaking.

Instead of a RemoteFunction you could simply handle everything inside of a server script with the PlayerAdded event.

The point was to change the visibility of the hat, which wouldn’t work server-sided