Eroor in trying to find any object that has an accessory class inside player and deleting it

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I just wanna delete any accessory the player has

  2. What is the issue? Include screenshots / videos if possible!
    I just wanna delete any accessory the player has and keeps printing nil

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    local player = game.Players.LocalPlayer
    local char = player.Character or player.CharacterAdded:Wait() and player.CharacterAppearanceLoaded:Wait()

    local accesory = char:FindFirstChildWhichIsA(“Accessory”)
    print(accesory)
    –2nd attempt
    local player = game.Players.LocalPlayer
    local char = player.Character or player.CharacterAdded:Wait() and player.CharacterAppearanceLoaded:Wait()

    local charchildren = char:GetChildren()

for i, v in pairs(charchildren) do
local accesory = v:IsA(“Accessory”)
if accesory then
accesory:Destroy()
end
end

– keeps printing nil
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block
```local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait() and player.CharacterAppearanceLoaded:Wait()

	
	local accesory = char:FindFirstChildWhichIsA("Accessory")
	print(accesory)
--2nd attempt
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait() and player.CharacterAppearanceLoaded:Wait()

	
	local charchildren = char:GetChildren()

for i, v in pairs(charchildren) do 
	local accesory =  v:IsA("Accessory")
	if accesory then
		accesory:Destroy()
	end
end


-- keeps printing nil 

Please do not ask people to write entire scripts or design entire systems for you. If you can't answer the three questions above, you should probably pick a different category.
1 Like

Try changing this:

To this:

for i, v in pairs(charchildren)
	local accesory = v
	
	if v:IsA("Accessory") then
		accesory:Destroy()
	end
end
1 Like

Not sure why but still doesnt work

sorry for so many edits, roblox was being weird