Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does == and ~= mean?

I don't really get it :P

2 answers

✓ Accepted answer

The == Operator

The == operator is the operator for comparing equivalent values.

val1 == val2 - if val1 is equivalent to val2.

local val1 = 4
local val2 = 2 * 2

if val1 == val2 then
	print('Equivalent!')
end

The above code would print Equivalent! because val1 is equivalent to val2.


The ~= Operator

The ~= operator is the comparing non-equivalent values! The exact opposite of ==.

val1 ~= val2 - if val1 is not equivalent to val2.

local val1 = 4
local val2 = 1

if val1 ~= val2 then
	print('Not Equivalent!')
end

The above code would print Not Equivalent! because val1 is not equivalent to val2.

1 comment

1

and "=" will change the value of something.

Both == and ~= are used in if or repeat - until functions. == means 'is equal to', and ~= means 'is NOT equal to'.

Example:

if Value == true then
	--Code
	elseif Value ~= true then
	--Other code
end

2 comments

0

Hmm, I see. Thanks for the fast reply bud :D

0

'if' isn't a function, it's a statement. 'repeat - until' isn't a function, it's a loop.

This discussion is preserved as it was. New answers, comments, and votes are closed.