Trying to check if a player has an Accessory that isn’t on the head.
--Make certain items transparent
for i, v in pairs(cloned_char:GetChildren()) do
if v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
if v:IsA("Part") or v:IsA("MeshPart") then
local int = v
if int.Name ~= "Head" then
local stand = int
stand.Transparency = 1
end
end
if v:IsA("Accessory") then
local accessory = v
for i, items in pairs(accessory.Handle:GetChildren()) do
if items.Name ~= "HatAttatchment" or "FaceFrontAttachment" or "HairAttachment" then
local acc = items.Parent.Parent
acc:Destroy()
end
if items.Name == "BodyBackAttatchment" then
end
end
end
end
The part at the end where it says v:Destroy() isn’t actually even running for some reason.
Are you sure it isn’t just finding something in one of the other if statements?
If it’s finding a shirt or Pants for example then it will not go through the rest of the elseif statements.
yeah. You should just use if statements to search for each item separately:
if v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
if v:IsA("Part") or v:IsA("MeshPart") and v.Name ~= "Head" then
v.Transparency = 1
end
if v:IsA("Accessory")then
Part1 = v.Handle.AccessoryWeld.Part1
end
if v:IsA("Accessory") and Part1 ~= cloned_char.Head then
print("Arrived")
v:Destroy()
print("Moving on")
end
I figured out the solution. The reason why nothing was working was that I was using another if statement when I should be using an elseif statement because they only work if the first option doesn’t fit the criteria.
Here’s the code:
--Make certain items transparent
for i, v in pairs(cloned_char:GetChildren()) do
if v:IsA("Shirt") or v:IsA("Pants") then
v:Destroy()
end
if v:IsA("Part") or v:IsA("MeshPart") then
local int = v
if int.Name ~= "Head" then
local stand = int
stand.Transparency = 1
end
end
if v:IsA("Accessory") then
local accessory = v
for i, items in pairs(accessory.Handle:GetChildren()) do
if items:IsA("Attachment") and items.Name == "HatAttachment" or items.Name == "FaceFrontAttachment" or items.Name == "HairAttachment" then
local acc = items
local access = acc.Parent.Parent
print("Keep: ".. access.Name)
elseif items:IsA("Attachment") and items.Name ~= "HatAttatchment" and "FaceFrontAttachment" and "HairAttachment" then
local ax = items
local axx = ax.Parent.Parent
axx:Destroy()
end
end
end
end