How to check if something doesn't equal to something?

Hello there, In the process of creating a minigame script I have ran into a slight issue, Im trying to check if A doesn’t equal to B.

Here is my script:

    local Titles = {"South-Korea","North-Korea","UnitedKingdom","UnitedStates"}

	local GetTag = math.random(1,#Titles)
	local PickTag = Titles[GetTag]
	local GetTag2 = math.random(1,#Titles)
	local PickTag2 = Titles[GetTag2]
	-- Make sure tags aren't the same
	if PickTag2 == PickTag then
		print("Chosen the same for each randoms. Redoing.")
		Status.Value = "Cannot continue SwordFight due to Game choosing "..PickTag2 .. " VS "..PickTag
			GetTag2 = math.random(1,#Titles)
			PickTag2 = Titles[GetTag2]
		until not PickTag == PickTag2 -- Here I want it so PickTag doesn't equal to PickTag2
		print("Selected a different tag!")

I don’t know if there is a way to do this or not, therefore Im asking the forum, Any help is appreciated!

1 Like

Use the ~= operator for this.


You should be using ~= as they said above, but your problem is the order of operations.
Lua is reading your code as this
(not a) == b
And if a is not false and not nil, then it will become false.
false == b
and that’s not what you wanted.
You can fix it with parentheses if you really wanted, but @Aerosphia has the correct solution.
not (a == b)