This answer's to be used as a reference
When coming into the if statement, some users do the following.
if Val == 1 or 0 then
end
Just by reading, what do you see? If it's still a bit hard to see, let's make it a bit more clear.
if (Val == 1) or 0 then
end
The issue's that it's not saying "if Value is equal to 1 or is equal to 0, then...", it's actually saying "if Value is equal to 1 or 0 is true, then..." Since numbers return truthy, if the first value's not 1, it will go to 0 and see that it's truthy, thus fire the following code.
The solution's to check the value individually, for example;
if Val == 1 or Val == 2 then
end
Here, it will check if Val is equal to 1 or if it's equal to 0.
Stuff touched on but not really explained
Truthy - Incapax did a good explanation of this. In a nutshell, values such as numbers are considered truthy when being evaluated.
If Statement - Evaluates a value whether it's true or false. (You probably know that though lol.)
If you have anymore questions, please let me know. :)
3 comments
use changed serversided
intvalue.Changed:Connect(function() if intvalue.Value > 50 then print('greater than 50') end end)
What do you mean?