Advanced Roblox Scripting Tutorial #7 - CFrame (Beginner to Pro 2019)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to another script in tutorial guys it is the Deaf King here that from the video and guys in today's video I'm gonna be teaching you about si frame now some of you actually asked this tutorial before and well here it is and um I just want to say guys this is not gonna be that easy okay I don't wanna like make you scared don't be scared guys you can get through it okay everyone can understand it but it's it's a little bit confusing at first so if you need to rewatch the video or you need to you know get some more stuff about the topic maybe you want to read something about it I will have some links in description below so yeah so if you get confused guys just just take a second to pause and think maybe if that helps do whatever you think is best so yeah anyways before we're gonna the video like I said always be sure to watch the beginner series first or else those will be very confusing to you so link to the beginner series is in description below but um yeah anyways guys it's good to start this okay so first things first what is see frame okay so see frame by definition is a datatype you used to rotate position through in position 3d objects okay now what that means is actually kind of makes sense but basically it's kind of like the vector3 value right so you know I like because if you make a part right and on the left you have over here you have position right the position is a property that you can change you know to move its position obviously right I can move it around with the we know typing over here so I can make that 20 and then it moves over there right and I can change any of these three values 30 you know whenever I want to change I can make it move any which way now basically see frame just did just that see frame actually it was the same thing as position but it also has rotation inside of it so if you click on the rotation tool up here and you go down - where's rotation okay there it is orientation what's called actually if you go to see orientation right here whenever I rotate it it actually changes the orientation right so that makes sense because you know it's the orientation of how it's turning stuff that way you know I was turned so you can change that with a script obviously I can get 60 and that basically is the orientation and then position you the same thing and obvious I just showed you that but you get the point right basically I can change the position and I can change the orientation with vector three values but the C frame what C frame is is it has both of them inside of one data type okay C frame stores a position and the orientation so yeah so actually I want to show you something real quick I wanted to show you something this may be a little confusing looking then I'm gonna put a script inside of the part okay and then I'm going to go ahead and do um Sprint's script dot parent dots C frame now look and this is gonna look really confusing now just just brace yourselves okay actually I don't know if I should show you this but I'm gonna show you now anyway so here we go okay so okay that looks really weird alright so there's a me zoom in so as you can see here I have the position of the first three values right or the position of the of the part right it's thirty third negative thirty one point five and then yeah I got five and then point two not moving a little bit cuz I touched it and it's not anchored so yeah but and then the the three over here is orientation are somewhere in here right and are you're probably wondering well if it's positioned which are these two values right here and it's also the rotation which are only three values why are there like six more here yeah so why are there ten total values now honestly guys don't worry about that right now okay I just don't want to worry about that there's there's ten values in C frame in total but the ones you want to remember now is just the orientation and actually at eleven they're my miscounted it there's eleven but the ones you want to worry about I should know there's ten I'm sorry okay there's only one ever about the ones you want to worry about are just the orientation and position okay so don't worry about that I'll explain that maybe in a future video one day but for now I don't want to confuse you with that all right basically all you need to know is that C frame stores orientation or like you know how its rotated or I mean and the position okay so that's what it stores and a few more things but that's look at that later all right so now you see this power here right I'm gonna show you how to move stuff with C frame and not just in like you know not in you know the workspace or in the thing over here all right I want to move this back to the middle I'll put it in ten ten ten okay so it's right there and actually that's not the middle but there you go I'll put in this guy a little bit okay there we go all right so here's our part right here okay I'm gonna come see the color of it so it's a little bit easy to see okay and now we're going to like adjust the part stuff okay so what we're gonna do first is actually get the variable for the parts that make it simple so local part is equal to script dot and then we're gonna do local new see frame okay what you don't have to do this at all if you don't want to I mean actually you do if you do this but local new see frame is equal to C frame and dot new okay now what I just do all right okay let me get rid of this part first actually I can create a C frame using C frame dot new right but I'm putting it inside of a variable called new C frame okay that's that's what I'm doing so local C frame is equal C frame new and then we can change the oh wow that's that's so weird okay okay okay okay so yeah logo seems you'll see for no new and then we can put values in here which will you want the part to be okay so the first three values so I can do like three five ten okay the first two values right now would be what this would be the position okay so in the new free C frame Eagle C frame out new it would be the position now I'm pretty sure I'm talking about vector three values so actually I did but vector three values we don't remember is like the same thing right it's it's positioned sort of in vector three values and I don't renamed C frame but I can name it you know new new position and then this would be the exact same thing as C frame I can change this Ephraim I want to do or vector three doesn't matter it would be the exact same thing but C frame is more like it's better to use because you're gonna use it more often and you can change the orientation with it as well so yeah anyways so now we have C frame not new right here right alright so what we're gonna do is just make it make it called you know make a random valued okay so we get three five ten all right so we're gonna put it three five ten okay and then we're going to go ahead and do C frame or no sorry red block or part not red block C frame or part C frame part dot C frames equals a new position okay that's what it needs to be I'm sorry I have some notice to my right because sometimes I confuse it gets confusing for me too but yeah okay so yeah part dot C frames equal to new position now what this is gonna do is this going to basically change the C frame of our part this part right here to the new position which we made in this variable right here so basically if you want to you can picture this this line of code right here you can also picture like this okay so that's the same exact thing crap alright so that's a that's the same exact thing right here as writing new position okay his loom position is equal to C frame okay so we're gonna go ahead and use the variable for now cuz I made it and here we go we're not gonna actually okay also guys one more thing I want to show you real quick you can actually you can actually run your game without having to spawn in so I can do run and it's gonna run the game for me right now so yeah see it moved okay so it's not anchored let me take it real quick but you get my point you can actually go over here on the top hit home and then change it to run and then you can just run it without him to spawn it which is pretty nice my name is let me run the script right now and show you what it does okay so it's gonna move it to the new position which was over here okay so that's what it did all right and moved it to the new position which oh my gosh okay which is which was over here okay so that's what that does now you're probably wondering okay so how do I rotate it now for that you're gonna use C frame dot angles so let me show that mean so she's not angles okay and then we're going to just make this play okay okay okay all right so this is gonna be looking for you like I said guys stay with me I'm actually gonna get rid of this variable right here because I want to keep it as simple as possible so we'll just change the parts to frame correctly not with a variable so part dot C frame C frame angles so this is at you change the angle of the seat frame right so what we would do is use three values and this is this is only three values right and if you guys notice I'm not sure get to do that but in C frame not angles up here it says number are X Y and RZ so it's saying that you know that the you know the rotation which actually not what it stands for but the of the x y&z it stands for radians okay now let me just actually let me write it a person I'll show enemy alright so what I want to do is I want to rotate it this little part right here 45 degrees on the okay on the on the what's it called the y-axis right that's what I want to do I'm gonna rotate it 45 degrees on this axis right here okay the middle one as you can see there all right so 45 degrees it's gonna look like it doesn't look like this okay so what I'm gonna do is you'd think I do 0:45 zero right you think I'd do that right but no you don't do that okay um what you actually want to do is whenever you put like the degree you want it's a rotate you want to put math dot rad and then the for the parameter you put the degrees you wanted to rotate now what is math dot radical longer okay so math dot rad basically converts their degrees into radians and you're probably wondering what are radians radians is like another type of way you can measure angles I think I don't know how to describe it but it's like trigonometry which I don't even understand is clearly I've never been to that I never took a trigonometry class before right I don't even understand it that much but basically all you need to know is if you want to convert you know the degrees or you want the degrees to you know to be in your here you need to make sure you put math dot rad now okay so a more about radians like one Radian is equal to 57 degrees so basically what is doing for you is it's converting a degrees to radians right so it's just converting the degrees which is 45 degrees so we want and we're converting it to that amount of radians which is what this this parameter wants it wants radiance right but this math that rad function does it for us okay I hope that makes sense I really hope it does like I said guys please pause the video pause the video if you like take a second to think but after this I'll have some more information for you later so don't worry okay alright so hopefully that makes sense like I said it doesn't just pause and think for a second then play again if you still can't remember it or still don't understand so now if I run this script okay what's gonna happen is this is gonna rotate and oh it move - okay wait why did it move I don't know okay that was weird but okay anyways but you see what you see what I did there it rotated right it rotated and it also moved if you're white move to be honest with you but I'm okay okay guys so I am back and um let me just say I'm sorry you're probably wondering it just cut here now I find out I found out why it moved actually and I didn't want to leave you guys on that cliffhanger they're just like you know wondering why I moved I wanted to know too but basically the reason why it moved right I'm citing just why so I had C frame right I had I made the angles right with C frame not angles and then I I'm sorry I'm sorry and then I put it on the new seat I put it on the C frame of the part right so I changed the C frame other part with this C frame about angles thing right and what it did was it moved it down here but it did rotate it and did what we wanted to but it also did something we didn't want it to which was move it okay I'm gonna did rotate now the reason why I rotated was because actually what it does when you use C frame cott angles is it resets the entire C frame so it also resets the position like if you notice here whenever I hit run this the position is actually zero zero zero which is completely reset to the you know to zero right so it resets the position to the basic C frame because if you use C frame dot new right C frame you can actually does he use that by itself or usually print it and it's just gonna give you look it's just gonna give you a zero zero zero zero zero ability you know it's like C but it gives you some ones in there I don't know why but basically the point is it reset the position to zero zero zero as you can see the first two zeros the first three position the values of zero so what you could actually fix that is whenever you use angles what you want to do is actually do part dot C frame is equal to part dot C frame and then times the angles right so basically what I'm doing here instead is I'm just actually doing the same exact thing right but I'm adding it to the C frame instead of just resetting completely okay so you're probably wondering why I'm using your ass tricks there the time is kind of just for it's not like it's it's not multiplying it but it's just adding it to it so as you can see here now if I run it it doesn't move at all so let me actually go back to the base plate and show you it doesn't move it keeps the same position which is what it was but it also changes the Engels by multiplying it to what it was which was zero zero zero now as you can see here you're probably wondering okay so why does it multiply but it's like I said guys it's just adding and yeah so now if we print the C frame right print the C frame and we run it we printed before and after um Oh what okay I don't know why did that you know what don't worry about that okay anyways the point is in front of before and after it does that and you know I'm just gonna make it cleaner we put it in a variable but there we go there we go and there we go so now it does the same thing it'll rotate it and there we go guys so yeah it looks pretty cool I like it rotates and it does what we need to do now obviously I said to be printing the C frame I actually want to see what it looks like because because the values all change right because you're setting the memory or something so okay I'm gonna put the values in change but whatever okay you get the point that's how it works that's what it does and that's how you rotate it so yeah and also guys because you ever see something else I'm watching something else too in case you ever see this from Euler angles XYZ it's the exact same thing as see if we brought angles it's the exact same thing okay so if we see from Euler angles which people probably won't use because it's kind of looks kind of dumb it's the exact same thing as angles okay as you can see here equivalent to from Euler angles XYZ and then from Euler angles yxz is just the same thing but the rotations are applied in a different order so yeah so it's different order so don't use this unless you want to confuse yourself but yeah so yeah that's what does also one more thing lots of herbs actually want to show you too let me change that back see from the needles is actually much if I should show you and I'll show you um let me see okay so basically if you want to okay let's say you have as part right here right first of all is here are the angles because I we don't need these angles anymore tired of these angles man okay see if I'm not new and then we'll just make that ten okay anyways so if you see our part here right if you want to actually just move the part like you want to like change the whole see frame and let's say for example you're trippin something right and you wanted to move a random part in the workspace by 10 on the z-axis right so you wanted to move it by 10 and let me get the you have views okay by 10 on the z-axis so this way right so you want to move it by 10 this way so to the right okay what you would actually do to do that is actually just what's called offsetting which basically means we're going to just add a seat frame to it so what I'm gonna do right now is add 10 or multiply which is the assembly you want to use to the C frame right here and it's gonna move to the right so as you can see here I'll actually move upwards because I have it on the 10 access or on the y axis which is my bad but you get the point right it moves so how you do that is just like I said you just have the C frame and then you multiply it to two something like that okay that's how it works also it's the same exact thing with the Radian so I don't have just showed you right so yeah and also one more thing I wanna show you too is you know I remember I told you about vector three values so I had vector three here now you're probably wondering okay so what do you want to add 10 to it with vector three actually what's weird because with vector three you actually put a plus sign and it does that see as you can see it and then it'll move to the right with vector three but if you use the star with vector three the script is like what banks going on and then it gives you an error right it's expects you just reframe so yeah basically that's what it means and yeah anyways you're learning about see famous videos I don't know why I showed you that but yeah also one more thing too I want to show you one more really cool thing actually never mind never mind okay that's pretty much all you know about C frames though guys we will be using them in the next tutorial and it sorta laughter but it's doing you're pretty simple okay learning about it in the first place it's kind of difficult but after you know it and afternoon like them this isn't all C frames like there's a lot more to it trust me but this is like the basic stuff about it which is pretty much all you to know for now but um yeah so it's pretty cool hope you guys enjoyed the video guys if you did like always be sure to leave a like well actually you should do that instantly I'm just kidding but anyways I hope that make sense to you guys like always please be sure to join me discord server discord link is in the description below and leave any comments me having the questions are any question we have the comments I'm sure you guys are gonna be a little confused but it's okay if you are guys like I said I have more resources linked below so anyways guys that's it hope you enjoyed and I'm so excited I'm glad I got us out of the way guys it's a bit confusing ones so yeah anyways guys peace out
Info
Channel: TheDevKing
Views: 89,231
Rating: undefined out of 5
Keywords: TheDevKing, Roblox Scripting Tutorial, roblox, studio, coding, tutorial, how to script on roblox, roblox studio, cframe tutorial roblox, cframe roblox, what is cframe roblox, what is cframe, how to use cframe, how to use cframe roblox, roblox cframe, roblox cframe tutorial, roblox scripting tutorial cframe, beginners roblox scripting tutorial, how to script on roblox 2019, roblox scripting cframe, cframe tutorial, cframe roblox tutorial, roblox cframe animation tutorial
Id: 9YqN8_VERps
Channel Id: undefined
Length: 18min 3sec (1083 seconds)
Published: Tue Aug 20 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.