Im honestly lost it just doesnt work and i dont know which one to use
COMMUNITY QUESTION
Whats the difference between = and ==???
4 answers
= 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
you use = when declaring variables or modifying them and you use == in conditional statements
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
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
