I'm trying to destroy accessories in characters for a specific team, but the code I'm using isn't working. I get no errors, but accessories still aren't destroyed. Everything else in the script works.
local teams = game:GetService("Teams") local zomb = teams.Zombie local zombiestuff = game.ReplicatedStorage.ZombieTeam game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function() if plr.Team == zomb then local char = plr.Character for i,v in pairs(zombiestuff.Regular.Meshes:GetChildren()) do v:Clone().Parent = char end local shirt = char:FindFirstChild("Shirt") local pants = char:FindFirstChild("Pants") if shirt ~= nil then shirt:Destroy() zombiestuff.Regular.Shirts.Shirt:Clone().Parent = char elseif shirt == nil then zombiestuff.Regular.Shirts.Shirt:Clone().Parent = char end if pants ~= nil then pants:Destroy() zombiestuff.Regular.Shirts.Pants:Clone().Parent = char elseif pants == nil then zombiestuff.Regular.Shirts.Pants:Clone().Parent = char end for i,v in pairs(char:GetChildren()) do --delete accessories if v:IsA("Accessory") then v:Destroy() end end end end) end)
local teams = game:GetService("Teams") local zomb = teams.Zombie local zombiestuff = game.ReplicatedStorage.ZombieTeam game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function() if plr.Team == zomb then local char = plr.Character for i,v in pairs(zombiestuff.Regular.Meshes:GetChildren()) do v:Clone().Parent = char end local shirt = char:FindFirstChild("Shirt") local pants = char:FindFirstChild("Pants") if shirt ~= nil then shirt:Destroy() zombiestuff.Regular.Shirts.Shirt:Clone().Parent = char elseif shirt == nil then zombiestuff.Regular.Shirts.Shirt:Clone().Parent = char end if pants ~= nil then pants:Destroy() zombiestuff.Regular.Shirts.Pants:Clone().Parent = char elseif pants == nil then zombiestuff.Regular.Shirts.Pants:Clone().Parent = char end local d = char:GetChildren() for i=1, #d do if (d[i].className == "Accessory") or (d[i].className == "Hat") then d[i]:remove() end end end end) end)
Hope this helps.