I'm trying to make an automatic hat remover for ranks that are below ID 17 in a group, but it doesn't work. Can someone help?
local Delete_All_Accessories = true; local Delete_Face = false;
local invisibleHead = false
local Reset_Character_Appearance = false; local Default_Character_Appearance = 384534;
local ps = game:GetService('Players')
local deleteHats = function(char, delete_All_Accessories)
print('here')
local children = char:GetChildren()
local ffc = game.FindFirstChild
local tbd = {}
-- Delete Hats
game.Players.PlayerAdded:Connect(function(Player) if Player:GetRankInGroup(2793208) <= 17 then for i = 1,#children do local child = children[i] if child.ClassName == 'Accessory' then print(child.Name) if delete_All_Accessories == true then table.insert(tbd, child) print('tis') else local handle = ffc(child, 'Handle') if handle then local hatAccessory = ffc(handle,'HatAttachment') if hatAccessory then table.insert(tbd, child) end end end end end
for i = 1,#tbd do tbd[i]:Destroy() end
end
local function CharacterAppearanceLoaded(char)
local children = char:GetChildren()
local ffc = game.FindFirstChild
-- Delete Hats deleteHats(char, Delete_All_Accessories) -- Delete Faces if Delete_Face then local head = ffc(char, 'Head') if head then local face = head:FindFirstChildOfClass('Decal') if face and face.Name == 'face' then face:Destroy() end end end --Make the head disappear if invisibleHead then local head = char:FindFirstChild('Head') if head then head.Transparency = 1 for _,child in pairs(head:GetChildren()) do if child.ClassName == 'SpecialMesh' then child:Destroy() end end end end
end
ps.PlayerAdded:connect(function(player) if Reset_Character_Appearance then player.CharacterAppearanceId = Default_Character_Appearance player:LoadCharacter() else player.CharacterAppearanceLoaded:connect(CharacterAppearanceLoaded) end end)