Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whats the difference between = and ==??? [closed]

Asked by 7 years ago

This question already has an answer here:

== and = and spacing

Im honestly lost it just doesnt work and i dont know which one to use

Marked as Duplicate by xAtom_ik, User#20388, DeveloperSolo, and cabbler

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

4 answers

Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
7 years ago
Edited 7 years ago

= works like this:

1local Name = "Test" -- = is used to set a variable

== works like this:

1local Name = "Test"
2 
3if script.Parent.Name == Name then -- == is used to check if two variables match each other
4    print('match')
5end
Ad
Log in to vote
0
Answered by 7 years ago

you use = when declaring variables or modifying them and you use == in conditional statements

Log in to vote
0
Answered by
noammao 294 Moderation Voter
7 years ago

You use == in if statements to check if something is worth exactly that but when you use = then you are setting the value. For example.

1Local  debounce = false       -- Here you are declaring a variable by using =
2 
3function hello()
4 
5    if debounce == false then   -- here we are looking if debounce is equal to false or not.
6 
7end
8end
Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
7 years ago

The "==" sign is used for comparisons

The "=" sign is used to define variables and all that jazz.

1a = fat

would work, but

1a == fat

would not work unless you're comparing in a print or in an until.

but, you can do

1a = fat --lets just say fat was defined before, now "a" points to the variable "fat"
2 
3if a == fat then --since a points to "fat", it will almost always return true, unless you do something dumb with the a/fat variables
4    print(a == fat) --since a == fat is correct, the statement a == fat will return true.
5end