So basically I have this badge that you can earn in-game by completing a specific quest, how do I make it so that any player who completes said quest and owns the badge will have a specific accessory (I have in studio > ReplicatedStorage) and it will be worn on their avatar as long as they’re in the game?
I want it to keep checking if the player owns the badge because they might own it while they’re in-game, so that they don’t need to rejoin to have their avatar wear the accessory.
Humanoids have a method to wear accessories.
As for checking if they own the badge without rejoining, you can just check on characteradded (in which case they’d have to reset) or on a loop if you’d like.
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MyBadgeID = (...)
local MyAccessory = (...)
function CharacterAdded(Player: Player, Character: Model)
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if BadgeService:UserHasBadgeAsync(Player.UserId, MyBadgeID) then
Humanoid:AddAccessory(MyAccessory)
end
end
Players.PlayerAdded:Connect(function (Player)
Player.CharacterAdded:Connect(function (Character)
CharacterAdded(Player, Character)
end)
end)