Advanced Roblox Scripting Tutorial #12 - Lerp / Lerping (Beginner to Pro 2019)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
alright guys welcome back to a brand new defecating tutorial and guys in today's tutorial I'm gonna be teaching you about LARPing so what is littering you may ask well let me go ahead and show you so this is exactly what you'll be learning with this tutorial so as you can see there like the little part right just moved into the blue part and it did it super smooth and super it looks super clean right and obviously you can you can picture how you can use that in games which is why I'm gonna teach you guys that today anyways before we get started make sure you you watch all my other tutorials or else you may be very confused because I'm not gonna be going over to basic stuff this is the advanced series so if you're new to robot scripting watch the beginner series first anyways link to that inscription but yeah anyway so let's go ahead and get started with this tutorial okay so first things first I'm gonna delete everything I have okay and then I'm going to delete everything I have and then insert two parts into your workspace okay now you saw it in that demonstration there example of LARPing but what exactly what exactly is LARPing so in my own words LARPing is where you have a part it's kind of like between service right if you guys know what tween services which you should but um it's kind of like tween service where you can have a part right and you can smoothly move it or you can actually just make it so well we just we get smooth smoothly move it with a for loop or you can make it so it's like a percentage of the way to another location now I notice how to make it fusing right now but basically what I mean is let's say this parts right here right so this is this is at 0% and then this is at 100% okay and then this part okay right here this part okay is that 0% because it's right here and this 100 so I move it like right in the middle it's at 50% right so that's what luring is you can move it like a percentage of the way to where you want it to go so yeah you'll see what I mean here in a second but that script I did at the beginning the where I move that part it's actually only three lines of code so you may look it may look difficult but it's not at all so yeah anyways I'm gonna waste time wasting your time and let's go started with the tutorial okay so first things first like I said make sure you have your parts and after that you're gonna want to go ahead and insert a script into your workspace so I'm gonna go ahead and do that I'm gonna insert a script so there we go and now we're gonna go ahead and find a few variables that our parts actually let me rename make sure you reading in one of your parts to like part two because they're both named part which you don't want so yeah rename one of your parts and then you'll be good but anyways so now they have parts two different part names I'm gonna go back to my script I'm gonna define the parts so I'm gonna do local part the equals game dorkface dot part and then local part 2 equals game Network space now part 2 all right now I have the plant parts okay so now I'm just gonna show you how to actually use the LARPing function and then I'm gonna show you how to make it move smoothly okay so basically how you do it is you get your part okay so part one we're gonna make it go fifty percent of the way to this part okay so actually I'm gonna put a marker here just I'm gonna the blue one is gonna be the marker okay just so you know where we started alright that's what it's gonna be alright and also it's on top of there but um yeah okay so the blue ones the marker that's how you know where we started alright so now what I'm gonna do is I'm gonna get my part one which is this part okay I'm gonna actually name that marker I'm gonna get my part one okay and I'm gonna type part dot C frame okay if you remember C frame which hopefully you do we don't remember I have a tutorial on it go watch that links in the description and works on my channel somewhere so just go watch that anyway so part about C frame equals part two or no equals actually sorry equals Part C frame and then lerp okay so what we're doing is we're setting the C frame of our part to something else by using the alert function okay and LARP stands for like linear interpolation I don't even know you can look it up but that's one of the best that it is okay so now let's say you use it okay so you do you know the colon lerp after C frame and then you have your two variables here are two parameters okay the first one is goal goal is where you wanted to go so where do you want our part to go we want it to actually go where this is we want to move it into here all right or move it that way okay that's the goal the end goal is right here okay so our goal is gonna be right our goal is gonna be that part that part C frame all right so I'm gonna do part 2 dot C frame okay let me zoom in a little bit because some of you actually were sitting it's a little hard to see which I clearly understand sorry about that I'll try to make sure something like that anymore but yeah anyways so make sure it looks like that okay so we're gonna lurk or so forth avoiding it the normal part dot C frame equals part not C frame and then we're gonna alert that C frame to the part two which is our first parameter of that alert function and the second parameter is how far do you want alert bit so what percentage okay and now hopefully you guys know how to convert decimal in a percentage what you do is just divide by 100 right I think yeah so like if I had 50 percent and I divide by 100 we can actually use the script to do it I would get 0.0 point zero five right so actually now I get point 0.5 sorry yeah there you go okay so what we could do is if you want a 50 percent out of a hundred okay what we do is we do 0.5 and if that math was wrong I'm sorry I don't think it was but my buddy's not working right now but anyway it's a silver regardless this is half away right point five is half away out of a hundred percent okay so what we're gonna do now is we're gonna run it and it's gonna move half away so watch this now it's not gonna do it smoothly because we're just luring it if you want to make it smooth we're gonna have to do a loop function which I'll show you in a second or a for loop which I'll show you in a second second but here you go so here we go and boom it moved half away all right now I mean I look like I flex my camera's not halfway but as you can see there and moved half away all right and now also I'll here's what I'll do look I'm gonna go ahead and run this and then I'm gonna pop out this script I know you never studios before okay it's a little weird I'm gonna put it in here okay and then actually the dresden knows a little scripting tutorial part okay you give you just say blur your script and then re-enable it it'll actually move so if i change the script right now and then irene able to script it's gonna it's gonna move so i'm gonna actually put it to point seven okay so that's point seven percent of the way which is seventy percent to that part okay so it's gonna move seventy percent of the way to this part and then i'm gonna disable it and rename it so it'll run the script again so disable green table and the seat now it's at point seven okay and i can put it to 0.8 and so on now i'm gonna show you how to actually make it look like and good okay see like okay now look at this i put it two point nine right and you see when it runs it goes she goes inside but it pops out and that's because can collide islam so if i turn oh crap yeah okay anchoring is often wrote the parts so filth of the map but if i if i turn kink aline off which i'm gonna do and then I turn anchoring off it's going to actually merge or take a turn anchoring off so I turn it going on yeah okay now I'm gonna show you how to actually do it with the for loop so it looks awesome more than nice okay so here we go me and put that back okay so now what we're going to do is we're going to make a floor loop so we're gonna do for I equals Z or actually at 0 so if you guys remember for loop syntax I'll give you a refresher okay so for I equals 0 this is our first where we want to start we want to start at 0 and then what do we want it to go to we want to go to one right because the lerp is only from point 0 to 1 so it's decimal right so we're going to go to 1 from 0 to 1 and we want to go by point zero one okay so it's gonna go up by point zero one every time it runs through the loop alright that's that's how it's gonna work all right there we go and then we're gonna put this in there okay and now we're gonna change we're gonna put a weight in here so actually see it happens if we don't put a weight it's gonna do it so fast that we won't even like see it's like the stab of a finger right so want to make sure you put a way in there and then we're gonna put I for the for the last parameter okay we don't want to put like a like percentage or how far we want it to be we wanted to actually slowly move with the loop all right so tonight move slowly now watch this guy's watch this here we go we're gonna hit the run and then watch it move I'm gonna move it over here because they really can it can be anywhere it's gonna go there but it's just gonna go um you know that way so here we go and boom look how cool that look cuz that looks so smooth like it's like tweening but it's just a lot simpler also if you guys are wondering like okay well why don't I use tweening or what I need to use lerp well it really I don't know the difference in the two honestly I can't tell you I'm not gonna lie to you I do not know the difference in the two I don't know if one is better for performance or whatever but I think there's a thread on there on the dev form so you can look that up if you want I mean it might be in the description or in the comment section if I could find it but um yeah so I don't know what the differences in the two is necessarily I don't know I don't know the difference but either way they're both useful and you'll see them both for sure and scripting so I wanted to teach you it as well anyways and we're not known that's sort of like that there's a little bit more to cover but look at cool that is right also another cool thing is it'll actually copy the rotation remember it's C frame so it's gonna copy the rotation as well so if I rotate it this way and that way and I make it look all cool right it's gonna actually wrote like move like that so watch this so boom look how cool that is great so it moves like that also it works the same way if there's not for loop right you can just you can just take that out of there and and then you can just set it to 0.5 it's also gonna copy the rotation right it's just gonna be halfway see it's not all I rotated it's halfway so yeah anyways another thing is to maybe you don't want to actually set it by a part okay we're gonna put that back in there but maybe you don't want to actually move it to a single part maybe you want to move it to a location where it was no part like what if I wanted to move it right here when it's rotated like this right obviously I can't show you them I'm moving my camera but what if what if I wanted to make it over here like that right so what I would do instead is I don't need that part where I can delete it so I'll also delete out on my strip - what I'm gonna do is I'm actually going to just set a manual seat frame so how you do that is you just do you know the C frame so let me show you okay so what you have to do is C frame dot new and then you do zero well actually you can you can do we don't have to zero but this is like this is like your remember the first few values of C frame this right here are gonna be your your position okay so this is like a picture like position all right so I wanted to move to zero five zero I don't need a movie I just really I'm gonna type in a random number like like like actually I don't want to be too big sixteen five seven or actually you know what twelve okay and then I'm gonna actually put it by eye again because it looks a lot nicer so we gonna see it mostly and now I don't know where that is honest I don't even know but I have my I have my script to tell me where this so we're gonna hit wrong when you see where it goes whoa okay like it moved over there and now also guys you know see frame also contains an orientation so you can also rotate it with C frame as well so what you would do for that is you would multiply it right you would did the same in the same parameter it's the same parameter so don't go past a comma but you would put ash to extendible the multiplication symbol and then you do see your frame dot angles right and then you set your angles so you do 0 90 0 now okay look this actually won't work now you think right you think okay I wanted to be 90 degrees on the y-axis I put a 90 there no it looks a little confusing but you actually have to do math dot rad and now let me zoom out a little bit you can't see at all but you have to do math dot rad and now oh gosh don't wish you for why I have to do math out rad I'll tell you right now so you see you have any time you put an actual number for angles you need to do math that rat now what math that rat is it's a function I'm pretty sure I said it before if I spend it again to this little confusing but it's a function that converts like the value that normally goes in here which is actually a radiance or radiance and it can reverse it to degrees okay so basically normally when you measure angles use degrees but they're in trigonometry and stuff they actually use radians which I've never used in real life but apparently they do right who knows but there that's why you have this little function here which basically converts the degrees into radians so it just you can actually use it with degrees right so whenever you put something in degrees here you need to make sure you put math out rat so if I wanted to make this 45 degrees I need to make sure I put math down rat now I don't know what that rotation even looks like but we're gonna find out right now so we're gonna hit play again and it's gonna rotate and it's also gonna move over there so let's hit play and boom look how cool that looks see is that simple honestly guys I love littering it looks really cool it's like tweeting obviously but it's it's kind of it's more ran it we can just plug in random numbers I guess you can do that too for tweeting but it's it's just easier to do it for for LARPing but yeah guys that's pretty much it that's pretty much the basics of looping I think there's a little bit more to know but that's pretty much all you need to know I don't think we're using too much but also guys I just want to give you a quick reminder for those of you watching this Orioles as it comes out I'm gonna be doing ok so for mine aren't clear all this stuff ok cuz I get a lot of questions I'm gonna be doing a GUI series ok so you know how there's stuff on your screen right if you're new to G you eyes you see how you have stuff in your screen I in games you have buttons under skin that say click me or buy this game pass I'll be making the entire series on everything there is to know about to you eyes so if you're worried about that and you're asking for that don't worry it is coming one day I promise ok after GUI series okay I'm gonna be making a series room and hit game together we're gonna make an entire game from scratch on video now it's gonna be really long I dunno that's that's probably a month or two away so it's kind of in the future but um that will be happening soon but yeah so first we're gonna finish the advanced series okay so we still have a lot more to learn and then we're gonna go to G wise because duis are important okay they need them in a game alright and then we're gonna go into actually creating an entire game from scratch with you okay so I'm gonna show you everything there's no I mean yarding everything is there now if you watch on my videos pretty much but yeah so anyways but for the next tutorial the one that's coming after this one I am expecting it to be data stores now what it is towards something you may ask data stores are where you save data so you know how you like in games really when you leave the game enjoy back you still have 50 coins that's what you've learned how to do so it's really exciting that's pretty much like literally like if you watch all my videos you're gonna basically know how to make a game from scratch but there's still a lot there's still some more stuff to learn like advanced stuff but the basics you can probably make a decent simulator with with like from here or from the beginning of my series my beginner series to like my next video you'll probably be able to make a pretty decent simulator so yeah anyways that's pretty much it guys hope you enjoyed the video like always if you did not already driven discord server link is in description below make sure you don't miss Court server guys I want to be doing some like game events some game dance maybe I'm not sure but um yeah sorry but last tour LTI knows a little little little boring maybe but um you know it was a stuff you gotta learn sometimes Safi I learned but yeah Andras it make sure to subscribe if you're new and I'll see the next tutorials anyways guys peace out
Info
Channel: TheDevKing
Views: 56,094
Rating: undefined out of 5
Keywords: TheDevKing, Roblox Scripting Tutorial, roblox, studio, coding, tutorial, lerp roblox studio, lerping roblox studio, lerp roblox, lerping roblox, how to lerp roblox, what is lerp roblox, how to use lerp in roblox, roblox lerp tutorial, roblox studio, how to script on roblox, thedevking, roblox tween service, roblox tweenservice, lerp tutorial, roblox lerping tutorial, roblox tutorial scripting, advanced scripting roblox, alvinblox, peaspod
Id: Yhg6_2UjtCM
Channel Id: undefined
Length: 16min 16sec (976 seconds)
Published: Fri Oct 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.