Issue with a Table

Im trying to make a table loop through all the image buttons inside a gui frame, and if the name of that button is the same as 1 of 3 values already set in the script then it would be outlined with a colour, however it seems to be outlining every image button inside the gui as long as one of the imagebuttons shares the same name as one of the values
This is my code:

		print("equipped; 1: "..equipped1.." 2: "..equipped2.." 3: "..equipped3.."// slctlvl = "..selectedlvl)
				for i,v in pairs(KS:GetChildren()) do
					if v:IsA("ImageButton") then
						if v.Name == equipped1 or equipped2 or equipped3 then 
							v.BorderColor3 = Color3.fromRGB(255, 255, 127) 
							print(v.Name)
							
					    end
					end
				end

In game the output look like this: (See how it prints both Example and Two despite only Two being equipped (And so it shouldnt print, as that print is under the if v.Name == line)
image

Any help would be appreciated, I dont use tables often so I wouldnt be suprised if its something simple, I just cant see it.

1 Like

Your logical error lies here:

What your code is logically looking for is if v.Name == equipped1 or equipped2 ~= nil or equipped3 ~=nil. Since you have both equipped2 and 3 set as a string, the boolean will always equate to true and enter the if statement.

Its annoying to write out but you need to compare the v.Name to each equipped1/2/3 variable.

1 Like