I want to shorten the if / then statement once again by removing unnecessary object.Name ==
's but it becomes weird
Checks every condition:
local object = script.Parent
if object.Name == "name1" or object.Name == "name2" or object.Name == "name3" then
print("Hello World!")
end
If the object name is name1
, name2
or name3
it will print Hello World!
---
Checks only the first condition:
local object = script.Parent
if object.Name == ("name1" or "name2" or "name3") then
print("Hello World!")
end
If the object name is name1
it will print Hello World!
but if the name is name2
or name3
it will do nothing
---
Checks only the second condition:
local object = script.Parent
if object.Name == ("name1" and "name2" or "name3") then
print("Hello World!")
end
It will print if its name is name2
---
Checks only the third condition:
local object = script.Parent
if object.Name == ("name1" and "name2" and "name3") then
print("Hello World!")
end
Now, it prints Hello World!
only when the object name is name3
I guess it checks the latest and
else the first or
So how do I keep them normal without repeating object.Name ==
?