I’m trying to remove some accessories from the selected player, but only their hats and hairs (as if their character was bald). It would run successfully prior to adding the lines which check r[i].AccessoryType so I believe the issue is there but there’s no errors in console??
local char = game.Workspace:FindFirstChild(player.Name)
local r = char:GetChildren()
if character:GetAttribute("NoAccessory") == nil or character:GetAttribute("NoAccessory") == false then
for i=1, #r do
if (r[i].className == "Accessory") then
if r[i].AccessoryType == "Hat" or r[i].AccessoryType == "Hair" then
r[i]:remove()
end
end
end
character:SetAttribute("NoAccessory", true)
end
Any help would be appreciated. (I’m also aware there’s probably many quicker and more effective ways to write this lol)