Not :IsA("Sound") not functioning properly

I have a line in one of my scripts that only adds a client instance to a table if it’s not a sound or another ClassName, however it still ends up adding all the default roblox sounds for animations with this line of code and I don’t know why:

	for i,v in pairs(playerChar:GetDescendants()) do -- defining descendantsTable
	if not v:IsA("Animation") or not v:IsA("StringValue") and not v:IsA("ObjectValue") and not v:IsA("Sound") then
		descendantsTable[v.Name] = true
	end
end

I think in line 2 you must use “and”, not “or”.

1 Like

I don’t think you can use and, or in the same line.

for i,v in pairs(playerChar:GetDescendants()) do -- defining descendantsTable
	if not v:IsA("Animation") and not v:IsA("StringValue") and not v:IsA("ObjectValue") and not v:IsA("Sound") then
		descendantsTable[v.Name] = true
	end
end

try this

Don’t know how I managed to end up doing that, thanks for noticing it.

2 Likes

Alternatively, you could try

for i,v in pairs(playerChar:GetDescendants()) do -- defining descendantsTable
	if not (v:IsA("Animation") or v:IsA("StringValue")) and not v:IsA("ObjectValue") and not v:IsA("Sound") then
		descendantsTable[v.Name] = true
	end
end