- What do you want to achieve? I want to be advanced
- What is the issue? I am a beginner. T-T
- What solutions have you tried so far? youtube
Example script:
local P = 3
if P == 3 then
print("yes")
end```
Example script:
local P = 3
if P == 3 then
print("yes")
end```
=
is used to set a variable to a value. Did you mean to use ==
to compare a value against another?
local Num = 3
local IsThree = (Num == 3)
print(IsThree) -- true
I always forget the other = sign and yes. I did mean to use it to compare values but I like to say “Checking”
By “advanced”, did you mean various ways to check the value? Or did you mean based upon input?
If the former, you could use a dictionary to check a value against multiple keys (which are assigned to values).
local AllowedPartTypes =
{
["Part"] = true,
["WedgePart"] = true
}
...
if AllowedPartTypes[Part.ClassName] then
If you meant the latter, then based upon input, you could have a different result done/outputted. For example,
local IsFour = 2 + 2 == 4
print("The math 2 + 2 == 4 is", IsFour)
Or
local StatementIs = false
print("This statement is", not StatementIs and "not" or "", "true")
If StatementIs
true, it will output
This statement is true
but if it was false, it would output
This statement is not true
If neither, mind clarifying what you meant by “advanced” please?
I mean like good, organized, kind of if statement.
After doing an if statement, while do loop, function, etc. you should indent your code like this:
local P = 3
if P == 3 then
print("yes")
end
I also like to put a blank line before if statements because it looks more organized but everyone has their own way of doing things.
That is how you make it organized but I do not know what you mean by “advanced”.
Look at the comment above and thanks!
If that is the solution, mark it as solution.