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 6 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
6 years ago
Edited 6 years ago

= works like this:

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

== works like this:

local Name = "Test"

if script.Parent.Name == Name then -- == is used to check if two variables match each other
    print('match')
end
Ad
Log in to vote
0
Answered by 6 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
6 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.

Local  debounce = false       -- Here you are declaring a variable by using =

function hello()

    if debounce == false then   -- here we are looking if debounce is equal to false or not.

end
end
Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago

The "==" sign is used for comparisons

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

a = fat

would work, but

a == fat 

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

but, you can do

a = fat --lets just say fat was defined before, now "a" points to the variable "fat"

if a == fat then --since a points to "fat", it will almost always return true, unless you do something dumb with the a/fat variables
    print(a == fat) --since a == fat is correct, the statement a == fat will return true.
end