Is there a different / faster / cleaner way to write this line of code?

I want to make this line of code better looking or just a better way in general of doing this.

if Value.ClassName == "Accessory" and Value.Name ~= "One" and Value.Name ~= "Two" and Value.Name ~= "Three" then
-- code 
end

Its a checker to see if a player is wearing hats and if the hat names aren’t the specified names then delete the hat.

The and statements just don’t sit right with me

local forbiddenNames = {
	"One",
	"Two",
	"Three"
}

if value:IsA("Accessory") and not table.find(forbiddenNames, value.Name) then
	
end
1 Like

Perfect thank you :troll::troll:____________________

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.