AshRPG12Join Date: 2013-08-30 Post Count: 238 |
When I came upon scripting. I used random sentences and I found a bluish-colored instance term in scripts called "and" lower-case letters. When you type in this without any editing symbols(e.g. --, (), etc), it appears dark bluish as if it was a special term alike "function", and etc. What is this term? I searched all over google but roblox wiki won't have any related results and yes, I did the roblox scripting wiki. If someone explains this very well, I will be appreciated. |
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
Also, I know a segment of the term's meaning. It does another script segment that is located inside a unclear situation such as "if" and "elseif", plus others. I cannot explain how to use this is my question here. |
|
CoinyeJoin Date: 2010-07-19 Post Count: 4347 |
It is used as a logical operator
For example,
true and true > true
false and true > false
false and false > false |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
A and B basically means like, if A is not nil or false, use B's value. Else use A's value.
Opposite is true for 'or' (A or B) |
|
|
example
wait(3)
local P1 = game.Players:FindFirstChild("Player1")
local P2 = game.Players:FindFirstChild("Player2")
if (P1~=nil) and (P2~=nil) then
P1.Character:MoveTo(P2.Character.Torso.Position) |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
A = true
B = false
if A = true and B = true then
print('Both are true!')
else
print('One of them are false!')
end |
|
eLunateJoin Date: 2014-07-29 Post Count: 13268 |
==* |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
@eL
Yea your right sorry. |
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
I actually knew the way to use it but my question was did I use it correctly? Sorry for not using the output but I also wanted to know it's full function meaning. |
|
|
"and" Makes it so for something to happen, multiple things need to have been done (rather than one)
Such as
do
if (1==1) and (2==2) then
print 'All is right in the world'
end
(Other operations can be included into an "and" statement as well)
do
if (1==1) and (2==2) then
print 'All is right in the world'
elseif (1==2) and (2==1) then
print 'The world is ending'
end
end
|
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
i made this forum thread because i thought I used it the wrong way or the script didn't execute both arguments
|
|
|
https://twitter.com/128Gigabytes/status/698367741674192896
c will be false unless it gets a pink t signal from a and b
If a or b sends a balck f signal it will stop the pink t signals from reaching c. |
|
|
Basically an argument like this:
if Player.Name == "IllumlZoldyck" and Player.Health = 100 then
print("Wow he's health")
end
|
|
|
Ah, a community-based question-answering scheme. Splendid.
The "and" keyword is merely a logical term within Lua that manipulates Boolean data values.
We can utilize the logical AND/and operator to determine whether certain logical criteria has been fulfilled.
An example would be the following:
x = 1 and 2; --This would return the value of the second operand, 2.
x = 2 and 1 --This would return the value of the second operand, 1.
bool = true and false; --This would return false.
bool = false and true --This would also return false.
If the operands supplied to "and" are mixed Boolean values, the returned value of the operation will be false. If the values are both true simultaneously, the returned value will be the secondary value of the logical "and" operation. |
|