The double equals sign is a comparator, while the single equals defines something. This allows you to write code such as
local foo = "example"
local blah = foo == "example"
This wouldn’t make sense if both used the same symbol. The case you described in your post would be attempting to set the fart variable to true, which the Luau interpreter doesn’t understand.
Also pro tip: Luau truthiness allows you to do if x then to check if a variable is not false or nil, rather than if x == true then.
as @eemsias said, == is a comparator to check if a is equal to b, where a and b represent variables.
In contrast, when you use =, you’re inserting something a value. = is the same thing as equal to.
In short, with the two equals you’re checking if something is equal to another thing, while with the single equal you’re implementing a value to it:
local a = "I'm a string!"
local b = "I'm a string2!"
local boolean = a == b --Would print false. It is the same as storing the boolean of "a == b", checking if they are the same.
if boolean then
print("They're the same thing!")
else
print("They're not the same thing!")
end
well there are multiple reasons, it makes coding simpler if you want to use other things such as
if fart then -- if fart exist
end
if fart == true then -- if fart is true
end
if fart == false then -- if fart is false
end
if fart <= 3 then -- less than or equal to 3
end
if fart >= 3 then -- more than or equal to 3
end
if fart ~= 3 then -- is not 3
end