How to remove a certain accessory from a certain person?

Hello, I have a problem, in my game, when clicking on an object, an accessory is put on the player, but then I need to remove it, and how to do this I do not understand


local Player = game:GetService("Players")
local Loc2 = script.Parent

Loc2.ClickDetector.MouseClick:Connect(function(guy, hey)
	local CARD = game.ServerStorage.Card
	local CARDClone = CARD:Clone()
	local hum =	guy.Character:WaitForChild("Humanoid")
	CARDClone.Parent = game.ServerStorage
	hum:AddAccessory(CARDClone)
	wait(2)
	hum:RemoveAccessory(CARDClone)
end)

There is no function called :RemoveAccessory
Instead loop through all accessories and find the accessory name, and destroy it.

for _, accessory in ipairs(humanoid:GetAccessories()) do
	if v:IsA("Accessory") and v.Name == "IdkName" then
		v:Destroy()
	end
end
1 Like

Desktop Screenshot 2024.10.18 - 15.23.15.23
I’m sorry, but I’m in scripting 0, and I don’t understand what that means.

1 Like

i believe you should replace all “v” with an orange line under to be “accessory”

1 Like


I don’t understand what’s going on, but thank you for taking the time.

1 Like

try replacing “humanoid” at line 33 with “hum”

3 Likes

YES BRO, IT WORK, THX YOU, СПАСИБО!

I gave you the script to work from, not to copy paste directly, my script works but js set up correct.

1 Like