Checking without == means value is there, or/and true?

Let’s say I have these 2 values:

local value1 = true
local value2 = workspace.BoolValue

If I do something like this:

if value1 then
print("Version 1: Backend")
end
if value2.Value then
print("Version 1: Explorer")
end

Will “Backend” and “Explorer” print?
Is there any difference between the above and below?

if value1 == false then
print("Version 2: Backend")
end
if value2.Value == true then
print("Version 2: Explorer")
end

Thanks!

“=” is used to set conditions, like variables, while “==” checks if something is equal to another

local part = game.Workspace.Part
if local part == game.Workspace.Part then
print("yup part=part")
end

Not really, in most cases. Something you should note though, is that

if value1 then
print("Version 1: Backend")
end

will only run when value1 is NOT nil or false, so you could replace value1 for a number or a part and it will still print.

1 Like

Yes, it is a bit different. When you check just “if Value then”, it checks if the value is either nil or false. If it isn’t, then it continues. So value1 == false is different, because it only checks if the value is false, and not nil. For example:

local x = false

if not (x) then
	print("Hello") -- this would print
end

if x == nil then
	print("Hello2") -- this would not print
end

if x == false then
	print("Hi") -- this would print
end

if x then
	print("Hi2") -- this would not print, since it's either false or nil
end
1 Like

That has… really nothing to do with my question, but thanks anyway.