This is supposed to sort through the accessories in a player's character and destroy any effects. It's not destroying the effects though.
Effects = {"Fire","Smoke","Sparkles","PointLight","SpotLight"} workspace.ChildAdded:Connect(function() for i, accessory in next, workspace:GetDescendants() do if accessory:IsA('Accessory') then for i, effect in pairs(accessory:GetChildren()) do for num = 1, #Effects do if effect:IsA(Effects[num]) then effect:Destroy() end end end end end end)
your issue is that you're searching through the Accessory object, and not the BasePart that the effect would be in.
local Effects = { Fire = true, Smoke = true, Sparkles = true, PointLight = true, SpotLight = true } --i just added this change so you wouldn't iterate through a list every time you wanted to check for a single object. idk if it's more efficient, but comes off a bit more elegant imo for i, v in pairs(accessory.Handle:GetChildren()) do if Effects[v.ClassName] then v:Destroy() end end
also i'm unclear about if ChildAdded works on children of the added Child (so in this case, a character is added, i'm not sure if it works on the Accessories inside the character.), so you might want to connect this to something like ...
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) for i,v in pairs(char:GetChildren()) do -- fixed xd if v:IsA("Accessory") then --etc --etc --etc end end end) end)