What is the difference between one "=" in a script versus 2?

I’m a new scripter and I was confused on what the difference is between one equals sign versus 2.

if order == 1 then
		order = 2

This is from a tutorial on how to make a katana. Notice that with the first line, “if order == 1 then” there is 2 equal signs, but with the second line, there is just one. What is the difference?

1 Like

so, one is to define a value

local a = 1

and two to make a “question” to the script

if a == 1 then
   print("is 1")
else
   print("isn't 1")
end
3 Likes

Two equal symbols is to check what the current value is and one equal symbol is to set the value.

1 Like

The double equal sign is used to check when a condition is met.

these might also help you;

== Equal to
~= Not equal to

1 Like

so, if you try to compare a value or anything like this

if 1 = 1 then

it won’t work, so you have to use “==” instead of “=”

if 1 == 1 then

and if 1 is the same with 1, the code inside it will run

2 Likes

local order = 1
if order == 1 then — its mean if order value is 1
order = 2 — its mean u change value of order from 1 to 2

1 Like

Ohhhh, I see! Thank you so much!

Examples:

== - if something equals to something
~= - if something is not equal to something
-= - value = value - number 
+= - value = value + number
>= - if something is greater than other thing
<= - if something is lower than other thing
1 Like

Wish I could give more than one person solution, thanks everyone!

Really == is used to know if something is true, that’s why you can do this

ImageLabel.Visible = (1 + 1 == 2)

is the short form of this

if 1 + 1 == 2 then
   ImageLabel.Visible = true
end
1 Like