Sorry if I did give a good explanation
The and method is used in an if then end statement to check the conditions for multiple argument(s), for example, if you wanted to check if Hat and Tool exists in Workspace, then you'd do;
if game.Workspace:FindFirstChild("Hat") and game.Workspace:FindFirstChild("Tool") then
print("Hat and Tool exists!")
end
The or method also checks the condition for multiple arguments, but checks if condition or condition2 then code end, or, in others words, if condition is not argument1 or condition2 is not argument2 then run code end code, this can be used for multiple purposes, like to check requirements, as the and method does, or to check either requirement, here's an example;
local condition1 = 5
local condition2 = 10
if condition1 == 4 or condition2 == 10 then
print("Yay! Code executed! :D")
end
But, if you wanted to print one Argument, then;
print(4 or 5)
print(4 and 5)
print(1 and 2 or 3 and 4)
Sadly, I can not explain why it only chooses one Argument like that. ;-;
You can also use the and method and or method method in the same if then end statement, for example;
local condition1 = true
local condition2 = false
if (condition1 and not condition2) or (not condition1 and condition2) then
print("Condition1 or Condition2 is true! :D")
end
But, in short, the and method is to check if condition1 and condition2 then run code end code, and the or method is to check if condition1 or condition2 then run code end code, but, in your code, you are not using it right, you are using the and method outside an if then end statement, or, you are only using one condition, let's fix up your code;
local apple = true
function Click()
if apple == true then
wait(5)
script.Parent.Parent:Destroy()
end
end
script.Parent.MouseButton1Down:connect(Click)
Ah, now doesn't that look much better? :) A clean code is a happy code. :D
Hope this helped!
3 comments
This is well explained TheAlphaStigma .
Lol, well, sometimes I think I don't explain codes too well, so, I try to explain as best I can. :)
A bit of a throw-back, think of it choosing the conditions similar to this: https://scriptinghelpers.org/questions/24278/