welcome back to my Roblox beginner scripting tutorial series my name is balev and in this episode we'll be discussing about operators so just like at the start of every single tutorial we've been doing up until this point we're going to uh click on our script that we created in the previous episode we're going to disable it and then we're going to insert a script inside of the workspace by searching up script like this inserting it and then we're going to right click and rename this to the name of the episode which is going to be
operators like this and then we're going to hit enter and then we're also going to delete our code here so now I can introduce to you what operators are so in the last episode we were introduced to if statements which basically allowed us to check for a specific condition that needed to be met before we executed specific parts of our script so an example of this is if we were to write if let's say true then we're going to hit enter and then we're going to write a print statement here saying this statement is true
just like this and if we were to run this inside of Studio obviously it's going to print so if we go to the game and hit play then it's going to say this statement is true because what we did was for this condition we literally gave a Boolean condition of true so this automatically makes it a true statement so that's the basics of using uh if statements but now for the purpose of this episode I'm going to be introducing to you a bunch of operators that can add more complexity to our conditionals so that we
can have very precise and effective uh comparisons that doesn't just restrict to one condition here we can have multiple conditions and we can even compare different things depending on what the operator we're using is so basically there's two types of operators that I'm going to be introducing to you and the first one is going to be logical operators so logical operators is what allows us to add more conditionals to the same if statement that we have over here so instead of just having one conditional we can have more than one conditional to see if more
than one condition is met before we go inside of this if statement and print out whatever's inside of here so the first logical operator that I'm going to be showing you is the operator called and and basically what we're going to do is on the right side of true we're going to hit space and then we're going to write an all lowercase and uh and then we can now put in a second conditional on the right side of this an statement so we're going to say U let's say false is all lerc case so this
statement Compares true and it also Compares false and in order for this statement to be valid for um for this conditional to be met both the left conditional and the right conditional needs to be true and in this case because the left side is true but the right side is not true that means this statement actually isn't going to uh run because this conditional uh was invalid so if we go into the game and hit play then what we should see is nothing inside of the output because we told this if statement that both the
left and the right side needs to be true in order for this statement to be valid uh based on this and logical uh operator so if we hit stop then I'm going to go back to our script and I'm going to be showing you another logical operator called or so all we're going to do is replace this and keyword with or just like this and basically what or does is it checks if one of these conditions is true so because this statement is true it's automatically going to go down to this print statement without even
checking whether this right side is true or not because for or all we need is just one of these statements to be true so that we can move on to uh whatever the code is inside um this if statement so that is how we use and and that is how we use or now if I were to make these inside of a different example with using numbers then I'm just going to delete this and let's say if 2 + 2 is equal to 4 and if let's say on the right side uh we can say
if 5 + 5 is equal to 10 so this left side returns true because 2 + 2 is equal to 4 and this right side is going to return true because 5 + 5 is equal to 10 so if we go into the game and hit play then what we should see in the output is this statement is true and if we hit stop and go back to our script and if let's say we were to change this statement on the right side side to be if 5 + 6 is equal to 10 so in
this case this is not going to be true anymore if we go into the game and hit play then it's not going to print anything inside of the output now if we were to stop and go back to our script and change this keyword to or instead of and then only one of these statements need to be true so if you go back into the game and hit play then what we should see in the output is this statement is true because 2 + 2 is equal to 4 and that's all we need to know
about now there's one more logical operator that I want you to know about and that is called not and we actually don't put that in between two different statements but instead we're going to put this before one conditional statement so what this is going to look like is we're going to delete this code that's over here and what I'm going to do is say if not like this and then we're going to put a conditional after this one so we're going to say if not true then print whatever is down here now basically what not
does is it gives us the opposite of whatever this conditional statement is over here so this true statement is actually going to return false because the not keyword gives us the opposite of true which is going to be false so if we go into the game and hit play then what we should see in the output is nothing being printed because this actually printed false instead of true now if we hit stop and then go to our script and then change this to false then it's going to return the opposite of false which is going
to be true so if we go into the game and hit play then what we should see is this statement is true and now if we were to hit stop and make this into a numerical uh example so I'm just going to delete this and what we're going to do is say if not 2 + 2 is equal to 4 then uh we're going to print the statement now obviously um this statement is true but because we have the KN before it it's actually going to return false now the thing that you have to be
careful about with this is we actually have to put in parentheses uh inside of our Boolean expression so let me show you what happens if we actually don't do this so I'm going to go into the script and hit play it's going to show in the output that it that it attempted to perform in arithmetic on Boolean and number and the reason it did this was so if we hit stop and go to our script it did this because it's reading this by saying if not two you can't compare not with a number so what
we need to do is insert parentheses like this so that we know that we're trying to compare this statement specifically so 2 + 2 is equal to 4 that's going to return true but the not is tied in front of it so it's actually going to return false so if we go into the game hit play then what we should see is this statement oppat turnic false so that is basically uh logical operators inside of Roblox studio and that is something important that we need to know about for our conditionals now the next set set
of operators I'm going to teach you is what's called relational operators and this has to do with the way we've been comparing um conditional numbers and this has to do with the way we've been comparing um equations inside of our um conditionals so I'm just going to delete everything we've had in this code up until this point and what I'm going to do is say if 2 + 2 is equal to 4 just like this so relational operators fall into what we've been doing with this comparison it's of here so if 2 + 2 is
equal to 4 which it is then it's going to return true this is one relational operator which is the equals relational operator but there's actually multiple different ways we can compare this relational operator that isn't just restricted to the equals and there's actually six relational types that I'm going to be showing you one by one so the first one is the equal sign and the next one I'm going to show you is the opposite of that which is going to be not equals and so basically what we're going to do is place this first equal
sign so we're going to hit backspace on this and we're going to replace this with a squiggly line that looks like this so I'm going to hold shift and then I'm going to hit the squiggly line now for me it's located on the um top left of my keyboard so I hope you're able to see it but when you do make this squiggly line before the equal sign this represents not equals so if 2 + 2 is not equal to 4 then it's going to print this statement over here now now this used to be
true but now this is actually going to return false because it's trying to say if 4 is not equal to 4 which is not true so if we go into the game and hit play then what we should see in the output is nothing because we're trying to say if four is not equal to four which is not true I hope this part is making sense to you so far so now there's two more operators that I want to show you so I'm actually going to delete these two lines right here and what I'm going
to do is say if 2 + 2 is greater than four so greater than is um indicated by this right arrow over here and basically what this means is if this number on the left side is greater than this number on the right side then it's going to um return a true statement now obviously this is not going to return true so if we add uh let's say 2 + 3 is equal to 4 so 2+ 3 is equal to 5 then it's going to be greater than four so this is going to be a
true statement so if we go into the game hit play then what we should see is this statement is indeed true so I'm going to hit stop and then we're going to go back to our operator and we can basically do the opposite by saying if 2 + 3 is less than so if we put in a uh left arrow symbol before whatever is going to be on the right side then this is going to compare if this is less than what's on the right side which obviously in this case five is not less than
four so this is not going to be true so if we go into the game and hit play then we should not see anything be printed in the output so I'm going to hit stop once again go back to our script and now there's two more relational operators I want to show you so we learned about greater than and we also learned about less than but now we're going to say if this is greater than or equal to so basically what this means is if this statement on the left side is greater than this statement
on the right side or if it's or if it's equal to whatever's on the right side then it's going to um make the statement true so if I say 2 + 2 is is greater than or equal to 4 2 + 2 is not greater than but it is equal to four so this statement is going to be true and we can do the same thing for uh the less than symbol as well by replacing this greater than symbol with the less than symbol just like this and this is going to compare if the less
if the left side is less than or equal to whatever's on the right side now I do want you to be careful because a lot of people get this mixed up where they have the equal sign on the left side before the operator on the right side so you can't say equals greater than this like it's some rocket symbol right here uh or less than like this you have to make sure that the operator is on the left side of the equal sign um when you are comparing greater than or equal to or less than
or equal to so that is the basics of using relational operators and logical operators inside of your scripts and um if there was some parts of the script that and if there were some parts of this video that confused you then I encourage you to rewatch certain parts of this video so that you can nail the down inside of your head so that you can understand how adding operators inside of your conditionals work inside of your scripts so with that being said for today's learning objective what I want you to do is continue experimenting with
adding more conditional statements by adding more operators inside of your conditional statements by I don't know adding another and statement with uh 5 + 10 is equal to I don't know 15 and you can just continue onward with what you want to add for your conditionals now another quick thing I want to mention is that you can have more than one um logical operator inside of here as well so we can have an and here and we can have an or here with another conditional and then we can have another and here with another conditional
and it can just keep on going for as long as you'd like so that's something else you can do with your conditionals and I recommend experimenting with adding logical and relational operators inside of your scripts and once you're done with that then I want you to go down to the comments and paste whatever code you feel comfortable sharing to everybody else so that everyone knows what you've been up to with these challenges as well as yourself so with that being said that's going to be it for this episode I hope you enjoyed it and I
will see you in the next episode take care