I’m writing a condition statement that does not seem to work like I want to.
If I were to check a bool value in the console, I would have to print(BoolValue.Value). However, in a condition, I am not sure if I need to do the same thing. The first condition would always pass as true if I compared the BoolValues by itself. But, if I put BoolValue.Value, nothing would execute.
I don’t really know what’s passed inside and I would like some clarification.
-- This would execute the first condition always
if BoolValue then
-- Code
elseif BoolValue2 then
-- Code that never runs
end
BoolValue is a reference to the actual object, which will always execute in an if statement because all values except for false and nil are effectively “true” when it comes to conditionals. If you do BoolValue.Value, this will either return true or false, which is exactly what you want.
So to answer your question, yes you would want to include .Value so you are referencing the Value of the BoolValue object instead of the object itself. If you didn’t do .Value, the code will ALWAYS execute as if it were true.