If anyone wants an example of how this can be used, review this code: local part = game.Workspace.Baseplate local function transformfunc (mat, trans) part.Material = mat part.Transparency = trans end transformfunc("Sand", 0.5 ) wait(10) transformfunc("LeafyGrass", 0) Its quite simple, the moment you start the game the baseplate will become sandy and half transparent, then after waiting 10 seconds the code will run the function again, except with different parameters. It can be a huge help when you want an item or value to go through different states after a certain requirement has been met. Parameters are used here simply to save time and simplify code.
This was short easy and simple great explanation yk, not only that, after finishing 10 tutorials, I’d recommend testing yourself by using all of them without any help, and note the ones that you struggle with and rewatch those vids. Getting practice in can help you remember those.
@@gabe1351 honestly just keep researching and practice writing the ones in tutorials and one day itll just click. What is it that you dont get about them?
@@gabe1351 you type "local ("here the name of your function") and then () the () are there for the parameters as you saw in the video after that you gonna type in your lines of codes and execute them with ("the name of your function") and then ()
alvin blox tought parameters while in his function video and i got so confused. but this is much better! plus alvin makes 20 min vids to explain and this is like 5
Helllo, U Helped me Alot Im Nomrallly an Animator for stickman figures then i learned how to Animate on roblox But then i said to my self, "I cant ony animate cause i dont even know how to put it in a key or how to make moves and Justu, punching,Magic etc Im so happy, i learned alot from you and u desserve more subs!
For those who don’t understand or still confused, parameters are like variables. Just think of them as variables, as in function(x, y). If you call function(1, 2), then x = 1 and y = 2. Since quite a decent amount of people see this, I’ll just add some more information, don’t read further if you’re easily confused. The variables that are passed into the parameters are actually copies. I’ll show you what I mean (and I haven’t touched Lua in a long time so I’ll be doing this with “pseudocode” mixed with C++): Let’s say we have a function called add that takes two integer variables… func int add(int x, int y) { return x + y; } And we have two variables called num1 and num2 outside, declared like so: int num1 = 0; int num2 = 1; Then passing that into the function - add(num1, num2) - should return 1 alright. Now let’s say we want to edit the parameters, adding 2x of each number (ex: x*2 + y*2). func int add(int x, int y) { x = x*2; y = y*2; return x + y; } So what do you think will happen if we run add(num1, num2) now? It should return 2 because 0*2 + 1*2 = 2. But here’s a question that comes up a lot with amateurs: are num1 and num2 multiplied too? No, the variables num1 and num2 are not changed AT ALL. This is because they’re passed in as parameters so int x and int y are simply variables that exist inside the function and the function only. Knowing some of you curious dedicated hardworking learners, you may ask, “Then how would I reference variables outside with my parameters?” Don’t worry, there’s a way. I’ll update this later because I’m on a phone. Alright here's the next part :) So in a language called C++, you can do so easily with something called "pass by reference". It works by defining the function as: function int changeNum(&num) Where the symbol & means "reference". However, this is (as far as I know) pretty much a C/C++ thing. We can work around it, however, in other languages like Lua. This requires a decent understanding of classes and objects. Just know that, classes are the templates to making objects, and they are basically "custom" data types programmers can write on their own. So we can have a "Person" class, with attributes like name and age (which has data types of String and int respectively), then we can mass produce people by making a ton of objects from that template. Weird analogy but I think it works (?). Moving on, primitive types are the basic building blocks of code. You've been using them already - int, double, boolean (true/false), char, etc. (Strings are objects btw because they are an array of char). What this basically means is that a String "references" where in the memory the first char is stored, and how many chars are after it, because we can only allocate so many data in a "block" (think binary 1s and 0s). We can't possibly have a whole chunk representing a string when they're just chars put together. If you see where I'm going with this, you're on track. Yes, we CANNOT pass by reference by doing function changeNum(num) because we're in Lua. But it's a different story if the parameter we're inputting is an object. Just make the primitive type into an object in any miraculous way possible. Store it in a table for example, idk lol. P/S: I haven't tested any of this second part but my guess should be right lmao you can test it on your own if it doesn't work uhh complain about it to me and I'll work on it. And some supporting evidence for my "shower thoughts": stackoverflow.com/questions/6128152/function-variable-scope-pass-by-value-or-reference
@@MrMr-oj7hl Best way to learn scripting is to do everything he does on the video whilst on RBX Studio, also once he does something key, try and copy what he just did but without looking at the video, until you remember it, so if you do that to everything, you will remember EVERYTHING.
great man, i watched your videos a long time ago but got caught up in some work so i forgot a lot, but its good to see that i had still subbed to your channel and now i can re learn it all! :)
Guys, if his explanation of parameters was confusing, I'll provide the explanation that worked for me. Basically, in his first example function, he writes: local function add(hotdog, ham) print (hotdog + ham) end Then the next line he types add(2, 3), and running the script puts 5 into the output. Basically, the function add() was defined as adding the two values in the parenthesis. In the first block of code, which acted like a definition of the function, the values are hotdog and ham. In the next line of code, which says print (hotdog + ham), it means that because hotdog and ham are in the parenthesis, it's gonna add the values hotdog and ham and print the result into the output. The function basically says, "If I have two values in my parenthesis, I will be adding those values and printing whatever I get after I added those values." So basically he used the parameters to help define what he wants his function to do and make it more useful in terms of what it can do. I like to think of parameters as parts of the definition of a function. Hopefully this was a helpful explanation.
the more i watch these tutorials and the more devking uses functions and variables, the better i feel. This truly is a beginners tutorial, thank you devking
Here before 6969 subs, I love your tutorials. I always wanted to learn lua, but all tutorials SUCKED, but yours is actually helpful. I will make the best games I can with all this when I reach the end of these tutorials
You are so underrated. You’re tutorials are amazing and you deserve more subscribers and viewers! You are so friendly and id much prefer to watch your tutorials than anyone else’s because you explain them so much easier and you’re very understanding. ❤️
Somehow this is quite better than any guide i've seen, i'm already an amateur, i've coded a few simple games in roblox. yet this already started explaining in the most understandable ways thing i never understood even after 1 year of programming. sweet.
Example 1. (using return from the last video) function Addition(a,b) local c = a+b return c end print(Addition(5,8)) -- The computer sees that we assigned 5 and 8 inside A and B. -- From that you can just think of it as like a math equation 5+8 -- Then we return the c which is 13 since we calculated how much 5+8 is we get 13. -- So just think of the things inside the () the same as you'd do when doing a variable -- It's just the same as this local a = 5 local b = 8 local c = a+b print(c) Here is the copy paste for the script shown in the video. function add(Hotdog, Ham) print(Hotdog) end add("Sweet", 2)
@@sandpaper1711 I think they are used like this. Lets say you have a input field where players can enter their names. So you just get the information from the input and put it in a parameter. This is what I think it is used
Also they do help in the long run of coding since it's easier to just edit the part in the () than changing every single mention of them in the function individually
I do recommend this tutorial to someone who's never learned a coding language before because if you already know a coding language you know like 80% of this course. It would be nice if there was a tutorial explaining their differences because the difference between most coding languages are small.
if any are still confused after reading all these comments, this is the basic example. at 1:42 he states that he can put a value in and then he does, and at 2:42 he should've said "you're probably wondering, how does 3 and 2 make 5 out of hotdog and ham?" its because it added them in order. this is what i was confused with, hope others find this helpful.
For anyone that's confused, parameter is basically a function variable. E.g local function add(x,y) if I call this function by doing: add(num1, num2) it's basically saying: x = num1 y = num2 This is assuming you already have variables outside of the function named num1 and num2 It might sound redundant at first, but you can do a lot with it, you just don't know enough to implement it.
Your videos are so easy to understand and you actually explain everything you do,than just write some code and dont explain anything about it.Ty TheDevKing for your videos,they are truly brilliant.
I have watched up to now and so far, you have been so extremely helpful! The only thing I wish you would do is use the scripts in a way you would normally use it instead of printing Hotdog.
@@practicalcucumber1395 maybe but for me its more confusing cuz i dont know how its supposed to be used it would make things less confising if he could like make a example with a script he normally uses this on so we know how its supposed/can be used
so if you guys came to it yet, parameters are just like substituting values in a math equation. you set the formula (or in this case, the parameters), and then u substitute the values to get the final answer. just a helpful guide if anyone found this confusing (pretty unlikely btw, he explained it great)
When you said functions might be getting a little boring now but I am actually enjoying learning how they work and how you give body to your function :) local function Me(Name, Year) print("My name is ", Name, ", it is the year ", Year, ".") end Me("Patt", 2021) I like to mess around and see what I can do with the functions, Hopefully I become a professional programmer in no time
Print(Hotdogs) basically tells the output section to say "Hotdogs" when you run the game, printing is mainly used to fix bugs, other than that it doesn't really have a use. Hope this helps!
After attempting to educate myself on LUA Scripting, and many fails I've finally found a way. You truly made it easier for me to figure out the basics for scripting and taking notes on the logic and all the possibilities was amazing and very useful. Bravo.
You explain it the best but I just don't know what to use any of these stuff for Can I please have a reply and tell me what to use functions for and other stuff!
Wow I use functions so much now, I am also making a game. The game is a car game. Instead of using he car chassis tune, I made my own, thanks to thedevking I can makes games now.
Because he calling "First "parameter with print its Hotdog .Look at top paramaters (hotdog"Firtstparameter",Ham"Second Parameter"). if he call print(ham) output will give 3x "2" because print calling "Second" parameter (sorry for my english)
If parameters are essentially variables, why not just define a variable (or local variable) for it? Why use parameters, that is what I am confused about.
parameters is just variables inside brackets and you can change their values anytime when you call (type the function) but its a bit specific in placement.
I'm in an entry level college computer science course and all of this is stuff we've been learning. If you can learn this stuff when you're 11 you'll be way ahead of most people, keep it up!
I wish I had have learned this stuff when I was 11 lol. this is a hobby for me but I just finished my first year of college so I have lots of time to practice now
very happy to hear but just don't expect it to be useful and take it as an hobby or POTENTIALLY useful because I have seen a lot of kids do it...just helping ;)
You make everything so easy to understand, I tried PeasFactory AlvinBlox and many other channels and this is the only one that actually makes me engaged and I learn from it. You explain it well and short. So you don’t waste time for 8 minutes you get straight into it and you actually explain extremely well. Thanks man.
For ppl who are confused, basically parameters are like variables for example local function Stuff() In these () i want to find stuff. To save our time finding it using a function instead of using an variable to find it we use PARAMETERS so, to write an parameter we put the thing we want to find inside of the functions () and now the code would be local function stuff(stuff) Now, since we found it, I can use the parameter how much I want to use it (for me) now I would (for me) I would return "stuff" if successful. for example local function stuff(stuff) return true print(" returned"..tostring(stuff)) And as you see, I use stuff again cuz I was looking for stuff using an function. And yeah! Hope you understand.. and if you don't understand to tostring method.. I will create an video about tostring
Okay if you don't know, here's the conclusion, hope you'll like it :). : Basically we're like making values like Hotdog, Ham in the video. then we call the function and add those two values together. Hotdog, Ham = 3,2 and the "strings" are like words even tho they're numbers like "3" "79" "Test" Integers are numbers.
for those who dont understand basically, lets say u type a parameter in the brackets ok? then u type print(name of parameter) u type both of the parameters. then u call the function at the end and then add the value u want inside the bracket. basically the parameters u first made dont have any value but after u call the function u add a value to the parameter and then it prints the value u gave to the parameter(s) to the output. hope this helped.
Thank you TheDevKing, With all your videos till now, this is my Script : local function myFunction1() local MakeFunction = 76 print(MakeFunction*2) end myFunction1() local a = 5 local function myFunction2(e, s) local MyFavouriteNumber = 5 print (MyFavouriteNumber+a) end myFunction2(5, 19) local function ReturnCommand() print("This is my Whole script that I made") -- Script return("Wow, this is Advanced!") end local ReturnC = ReturnCommand() print (ReturnC)
You can also add variables when you define the parameter for example: local Number4 = 4 local function add(FirstNumber) print(FirstNumber + 2) end add(Number4)
if youre wondering how it was able to print the function even though the print was AFTER calling the function, its because the print is part of the function. the function IS printing, so when you call the function, youre just printing it. (i was pretty confused on this for a while so i hope this helps anyone else)
its like Vars and each Var you giving it a different value of either a number or a word and it prints the results , btw is this playlist st ill good to watch in 2022 ?
local function car(firstpart, secondpart, thirdpart) print("car contains", firstpart, "and", secondpart, "and", thirdpart) end car("engine", "windows", "frame") an example :)
If you guys still don't understand parameters, go watch alvin blox's tutorial about it on episode 3 on his beginner scripting tutorial guide on the timestamp: 5:02 as it is quite helpful.
In this case, hotdog was the variable that was holding the value "sweet" and the 2 next to sweet was used to give the variable hamburgers a value. So hotdog = "sweet" and hamburgers = 2
In the parameter it says Hotdog, Ham but he only printed Hotdog in the function which when he called the function the parameter only recognized the Hotdog which equals Sweet. This is probably a bad explanation so you have any questions just ask.
You cannot print 2 with the string for example you cannot print sauce with a number after and that’s why he only put print hotdog if you look closely if he put hotdog + ham it would cause an error hope this was helpful
I am surprised at how little confusion I have about all these, especially since I'm taking notes I got through scope and returning with a good idea of what it is
thanks for the idea of taking notes, idk why I didn't think of that earlier! I kept forgetting everything from the earlier videos but just rewatched them and took notes
I might be late xD, i've just started roblox studio yesterday and i've been doing animations and scripting, i dont understand what functions are for, what is Parameter, What scope and Return are for, what string is (which i think is the ("Hotdog") thing, please answer if any of you guys know or you DevKing
@SaadTahir-yx1gt Thats nice! There is also an advanced tutorial just so you know :D i kinda took a break since it just got boring and i lost motivation but im going to get back on my feet sooner or later
I get that when you talk abt functions and parameters or returns that you're using the print example to show what they do but people want to know how they can actually be applied when scripting a game not just printing words into output.
so please correct me if im wrong but a practical example would be a fighting game, and use it to create a punch function. you could use the parameter to have, for example, a normal punch and a heavy punch?
for those who are confused an easier way to do this is by doing local hotdog = 3 local ham = 2 now you've set the values into these variables/parameter's as you can see this is a bit easier and you don't have to do add(3,2) -- this is a bit confusing now you can do print(3,2) for those who are still having a problem this is how you do it function add(hotdog, ham) local hotdog = 3 -- btw this is what they mean by saying parameters' are just like variables because they are local ham = 2 -- telling the function what to do print(hotdog + ham) end) now do -- add() -- as you can see this is a bit easier then doing add(3,2)
Only if 2 is also a string. add("sweet", "2") would work But if you used add("sweet", 2) it would return an error, bc in a static typed language (u dont need to know this) as the case of lua, you can only add param/variables of the same type (string + string, integer + integer, etc)
im still learning so correct me if im wrong but for people who dont understand Hotdog is the same as "local Hotdog = 3" and Ham is the same as "local Ham = 2" so when you print "print(Hotdog + Ham)" its like printing 3 + 2
Hey guys! Be sure to join the discord server if you have any questions or if you would like to meet me! discord.gg/FKcSyRh
Why there no replys?
@Builderman cool
The invite do be expired
Yeah
Im so confused tbh WHY in the world is this whole output thing even neccesary
If anyone wants an example of how this can be used, review this code:
local part = game.Workspace.Baseplate
local function transformfunc (mat, trans)
part.Material = mat
part.Transparency = trans
end
transformfunc("Sand", 0.5 )
wait(10)
transformfunc("LeafyGrass", 0)
Its quite simple, the moment you start the game the baseplate will become sandy and half transparent, then after waiting 10 seconds the code will run the function again, except with different parameters. It can be a huge help when you want an item or value to go through different states after a certain requirement has been met. Parameters are used here simply to save time and simplify code.
good example thx
great example
OOOH i get it now. Thanks!
Thank you so bro, you helped me understand parameters on a whole another level. Thanks!
This was short easy and simple great explanation yk, not only that, after finishing 10 tutorials, I’d recommend testing yourself by using all of them without any help, and note the ones that you struggle with and rewatch those vids. Getting practice in can help you remember those.
Holy. Thank you sir, you're the only individual who has explained parameters in a way so that I could understand them.
Was just gonna comment this.
Watch peasfactory
@@tentix9022 thx man 😄
@@MarioMario-yb3iz lol no probs
Neoory doesn’t matter how long it is as long as it helps
what is with this man and hotdogs
hotdogs r cool
Let's just say that he is always hungry and he loves eating hotdogs...
ik i was gonna comment that lol
He is spending 1000$/month on hotdogs.
Plot twist his side job is a hotdog stand
Hotdogs are the student that always gets picked, if he calls in sick the teacher will just call him on the phone.
What
@@valeriyaaslanov3254 ok
I GET IT LOL
I am so confused
But I’m never giving up! I will watch this series over and over if I have tooo!
same, i think this is my 3rd time rewatching the beginners series
What are you confused about? These are pretty simple for the most part. I cam answer your question about this. If you still have questions.
@@NewsOnQueue I don't understand how to do functions
@@gabe1351 honestly just keep researching and practice writing the ones in tutorials and one day itll just click. What is it that you dont get about them?
@@gabe1351 you type "local ("here the name of your function") and then ()
the () are there for the parameters as you saw in the video
after that you gonna type in your lines of codes and execute them with ("the name of your function") and then ()
TheDevKing: i need a name
hotdog: :I
TheDevKing: ok, i'll use you
Even a 8 year old could become a scripter after watching this. I should know(:
@@blinkxero6756 are you saying you're an 8 year old?
No I'm not
@@imdurpy4145 i am around that age LOL
i am learning script
@@sushi7910 did you learn it yet
others tutorials: 20 minutes
TheDevKing tutorials: 5 minutes
thx god!
lol
Not even 5 min there like 3 minutes
Other channels usually explain everything and try to miss nothing.
@EpicGreenYoda true
alvin blox tought parameters while in his function video and i got so confused. but this is much better! plus alvin makes 20 min vids to explain and this is like 5
Helllo, U Helped me Alot Im Nomrallly an Animator for stickman figures then i learned how to Animate on roblox But then i said to my self, "I cant ony animate cause i dont even know how to put it in a key or how to make moves and Justu, punching,Magic etc Im so happy, i learned alot from you and u desserve more subs!
Thanks man :)
@@TheDevKing hi devking
@@TheDevKing hey Dev King can I add you on roblox?
@@TheDevKingI don’t understand the function part in part 5,6,7 I just wanted to tell u it is ok if u ignore me :(
For those who don’t understand or still confused, parameters are like variables. Just think of them as variables, as in function(x, y). If you call function(1, 2), then x = 1 and y = 2.
Since quite a decent amount of people see this, I’ll just add some more information, don’t read further if you’re easily confused. The variables that are passed into the parameters are actually copies. I’ll show you what I mean (and I haven’t touched Lua in a long time so I’ll be doing this with “pseudocode” mixed with C++):
Let’s say we have a function called add that takes two integer variables…
func int add(int x, int y) {
return x + y;
}
And we have two variables called num1 and num2 outside, declared like so:
int num1 = 0;
int num2 = 1;
Then passing that into the function - add(num1, num2) - should return 1 alright.
Now let’s say we want to edit the parameters, adding 2x of each number (ex: x*2 + y*2).
func int add(int x, int y) {
x = x*2;
y = y*2;
return x + y;
}
So what do you think will happen if we run add(num1, num2) now? It should return 2 because 0*2 + 1*2 = 2. But here’s a question that comes up a lot with amateurs: are num1 and num2 multiplied too? No, the variables num1 and num2 are not changed AT ALL. This is because they’re passed in as parameters so int x and int y are simply variables that exist inside the function and the function only. Knowing some of you curious dedicated hardworking learners, you may ask, “Then how would I reference variables outside with my parameters?”
Don’t worry, there’s a way. I’ll update this later because I’m on a phone.
Alright here's the next part :)
So in a language called C++, you can do so easily with something called "pass by reference". It works by defining the function as:
function int changeNum(&num)
Where the symbol & means "reference". However, this is (as far as I know) pretty much a C/C++ thing. We can work around it, however, in other languages like Lua. This requires a decent understanding of classes and objects. Just know that, classes are the templates to making objects, and they are basically "custom" data types programmers can write on their own. So we can have a "Person" class, with attributes like name and age (which has data types of String and int respectively), then we can mass produce people by making a ton of objects from that template. Weird analogy but I think it works (?). Moving on, primitive types are the basic building blocks of code. You've been using them already - int, double, boolean (true/false), char, etc. (Strings are objects btw because they are an array of char). What this basically means is that a String "references" where in the memory the first char is stored, and how many chars are after it, because we can only allocate so many data in a "block" (think binary 1s and 0s). We can't possibly have a whole chunk representing a string when they're just chars put together. If you see where I'm going with this, you're on track.
Yes, we CANNOT pass by reference by doing function changeNum(num) because we're in Lua. But it's a different story if the parameter we're inputting is an object. Just make the primitive type into an object in any miraculous way possible. Store it in a table for example, idk lol.
P/S: I haven't tested any of this second part but my guess should be right lmao you can test it on your own if it doesn't work uhh complain about it to me and I'll work on it.
And some supporting evidence for my "shower thoughts": stackoverflow.com/questions/6128152/function-variable-scope-pass-by-value-or-reference
aye i appreciate your help
thank you OH MY GOSH
i understand it now but what would be the point of them if u could just print x,y or whatever u put
@@josh-ug3qw I don't know but it'll probably be more useful later on
mate thanks for that
hi i am litterilly watching this hole series all night he sun is just coming up
@@MrMr-oj7hl Best way to learn scripting is to do everything he does on the video whilst on RBX Studio, also once he does something key, try and copy what he just did but without looking at the video, until you remember it, so if you do that to everything, you will remember EVERYTHING.
@@MrMr-oj7hl Your welcome :)
Tysm for the tip
@@ClassyGamesTMtysm for the tip
Throughout the whole series I noticed something
DevKing likes hot dogs
great man, i watched your videos a long time ago but got caught up in some work so i forgot a lot, but its good to see that i had still subbed to your channel and now i can re learn it all! :)
here before 7,000,000,000 subscribers! dude your the best
lol
To be honest I think it should be 7.7 billion though
To be honest I think it should be 6.9 bilion though
@@pranavmoolan8524 lol true
this comment was a year ago and you still replied just now lol
Guys, if his explanation of parameters was confusing, I'll provide the explanation that worked for me.
Basically, in his first example function, he writes:
local function add(hotdog, ham)
print (hotdog + ham)
end
Then the next line he types add(2, 3), and running the script puts 5 into the output.
Basically, the function add() was defined as adding the two values in the parenthesis. In the first block of code, which acted like a definition of the function, the values are hotdog and ham. In the next line of code, which says print (hotdog + ham), it means that because hotdog and ham are in the parenthesis, it's gonna add the values hotdog and ham and print the result into the output. The function basically says, "If I have two values in my parenthesis, I will be adding those values and printing whatever I get after I added those values."
So basically he used the parameters to help define what he wants his function to do and make it more useful in terms of what it can do. I like to think of parameters as parts of the definition of a function.
Hopefully this was a helpful explanation.
Nice! Very simple and helpful. Thank you, man.
Thank you this made me understand it better
Tysm
@@theroomateisamuffin9524 K-K-K-K-KAKYOIN!
@@IX_4 everytime i comment someone says that lmao, you have a nice short name btw
the more i watch these tutorials and the more devking uses functions and variables, the better i feel. This truly is a beginners tutorial, thank you devking
Here before 6969 subs, I love your tutorials. I always wanted to learn lua, but all tutorials SUCKED, but yours is actually helpful. I will make the best games I can with all this when I reach the end of these tutorials
Omggg 69 FUNNInnumMABERRR RR R R R
You are so underrated. You’re tutorials are amazing and you deserve more subscribers and viewers! You are so friendly and id much prefer to watch your tutorials than anyone else’s because you explain them so much easier and you’re very understanding. ❤️
Lerua f
Lerua whoops
Alternate title: print but more complex
nope
@@HiBye-rq2mr 17h ago ok
more like local but more complex
fucking asked?
no its not print but more complex sorry if im being rude im not trying to be
this series of 4-12 minutes long videos have been more useful than a complete 48 minute long video
ty so much(sorry for bad english)
Somehow this is quite better than any guide i've seen, i'm already an amateur, i've coded a few simple games in roblox. yet this already started explaining in the most understandable ways thing i never understood even after 1 year of programming. sweet.
i jsut going through taking notes as i go, usually one page per video but im trying my bestg
Example 1. (using return from the last video)
function Addition(a,b)
local c = a+b
return c
end
print(Addition(5,8))
-- The computer sees that we assigned 5 and 8 inside A and B.
-- From that you can just think of it as like a math equation 5+8
-- Then we return the c which is 13 since we calculated how much 5+8 is we get 13.
-- So just think of the things inside the () the same as you'd do when doing a variable
-- It's just the same as this
local a = 5
local b = 8
local c = a+b
print(c)
Here is the copy paste for the script shown in the video.
function add(Hotdog, Ham)
print(Hotdog)
end
add("Sweet", 2)
so is there really any purpose to them? Do they like, make your game less laggy or something?
@@sandpaper1711 I think they are used like this. Lets say you have a input field where players can enter their names. So you just get the information from the input and put it in a parameter. This is what I think it is used
Also they do help in the long run of coding since it's easier to just edit the part in the () than changing every single mention of them in the function individually
I do recommend this tutorial to someone who's never learned a coding language before because if you already know a coding language you know like 80% of this course. It would be nice if there was a tutorial explaining their differences because the difference between most coding languages are small.
if any are still confused after reading all these comments, this is the basic example. at 1:42 he states that he can put a value in and then he does, and at 2:42 he should've said "you're probably wondering, how does 3 and 2 make 5 out of hotdog and ham?" its because it added them in order. this is what i was confused with, hope others find this helpful.
For anyone that's confused, parameter is basically a function variable.
E.g local function add(x,y)
if I call this function by doing:
add(num1, num2)
it's basically saying:
x = num1
y = num2
This is assuming you already have variables outside of the function named num1 and num2
It might sound redundant at first, but you can do a lot with it, you just don't know enough to implement it.
@PubxKitty911 for this you dont have to add " on Sweet unless it is used at the bottom called argument
THANK YOU SO MUCH I UNDERSTAND NOW!!!! Many hugs and *hotdogs* for you 😊
My school : takes 2 years to get to function
TheDevKing : your wish have came true
Your videos are so easy to understand and you actually explain everything you do,than just write some code and dont explain anything about it.Ty TheDevKing for your videos,they are truly brilliant.
this guy exists yet people still dont know how to script this guy is a GIFT
I have watched up to now and so far, you have been so extremely helpful! The only thing I wish you would do is use the scripts in a way you would normally use it instead of printing Hotdog.
that would make it confusing for people who get lost easily. It's a lot more to take in instead of just the topic of the video.
@@practicalcucumber1395 maybe but for me its more confusing cuz i dont know how its supposed to be used it would make things less confising if he could like make a example with a script he normally uses this on so we know how its supposed/can be used
@@justarandomguywholovesanim726 for real
he's trying to express his likings for hotdogs
so if you guys came to it yet, parameters are just like substituting values in a math equation. you set the formula (or in this case, the parameters), and then u substitute the values to get the final answer. just a helpful guide if anyone found this confusing (pretty unlikely btw, he explained it great)
I am learning so much! I could not thank you enough! :D
Bro, I watched TONS of tutorials and none of them made me understand but u did. I will sub to you
local function amongus(imposter, crewmate)
print(imposter+crewmate)
end
amongus(10,1)
This guy really love hotdogs... xD
i've been scripting for 1 year and i never learned i just watched others and im really starting to grasp this
When you said functions might be getting a little boring now but I am actually enjoying learning how they work and how you give body to your function :)
local function Me(Name, Year)
print("My name is ", Name, ", it is the year ", Year, ".")
end
Me("Patt", 2021)
I like to mess around and see what I can do with the functions, Hopefully I become a professional programmer in no time
Same lol
TheDevKing: **tries to think of an example for variables**
TheDevKing: h o t d o g
Example:
local function multiply(arg1, arg2)
return arg1*arg2
end
local Variable = multiply(6, 2)
print(Variable)
it will print 12 because 6x2=12
This comment made me understand the video, thanks man
I was understanding the video but now I see your comment and it just ruined everything
Can u. Make it simpler
i swear this dude will unknowingly teach someone that will become a popular roblox dev in the future
probably what happened with the creator of get a snack at 4 am. she mentioned thedevking in the credits page for his tutorials
local function add(Number1, Number2, Text)
print(Number1+Number2..Text)
end
add(1,3," yas")
bro u deserve way more views ur tutorials are great
Hello! I know I am late since this video is 4 years ago but, may i ask what print(Hotdogs) does in the code?
Print(Hotdogs) tells the script to say "Hotdogs" in the output, the output is that thing on the bottom where all the numbers and letters are printed.
@@Gorillix2024 and hotdogs = 3,2 so it prints 5
Print(Hotdogs) basically tells the output section to say "Hotdogs" when you run the game, printing is mainly used to fix bugs, other than that it doesn't really have a use. Hope this helps!
After attempting to educate myself on LUA Scripting, and many fails I've finally found a way. You truly made it easier for me to figure out the basics for scripting and taking notes on the logic and all the possibilities was amazing and very useful. Bravo.
You explain it the best but I just don't know what to use any of these stuff for
Can I please have a reply and tell me what to use functions for and other stuff!
Wow I use functions so much now, I am also making a game. The game is a car game. Instead of using he car chassis tune, I made my own, thanks to thedevking I can makes games now.
The Most Helpful Person I Ever Watched, Continue Bro
But couldn't I just add a variable. Why is there no "2" when called with a string?
Because he calling "First "parameter with print its Hotdog .Look at top paramaters (hotdog"Firtstparameter",Ham"Second Parameter"). if he call print(ham) output will give 3x "2" because print calling "Second" parameter (sorry for my english)
@@EB-db1us Oh that's makes more sense.
His tutorials are so good that I instantly understood what parameters are at 1:30
Are you hungry watching these? 😂
Thank you so much tho!
Your tutorials are so simple and I love your jokes
If I were to pick any UA-cam tutorial i would choose yours :D
If parameters are essentially variables, why not just define a variable (or local variable) for it? Why use parameters, that is what I am confused about.
Watch alvin bloxx his tutorial also explains about parameters check it out.
parameters is just variables inside brackets and you can change their values anytime when you call (type the function) but its a bit specific in placement.
i'm eleven and im trying to learn as more as i can so it can help in future btw i want to be a game dev.
I'm in an entry level college computer science course and all of this is stuff we've been learning. If you can learn this stuff when you're 11 you'll be way ahead of most people, keep it up!
I wish I had have learned this stuff when I was 11 lol. this is a hobby for me but I just finished my first year of college so I have lots of time to practice now
very happy to hear but just don't expect it to be useful and take it as an hobby or POTENTIALLY useful because I have seen a lot of kids do it...just helping ;)
@@TeamTrapMike Yeah he's right all of this will forever be needed in order to get into the complicated stuff.
@Mike C I’m actually 10 and almost in the advanced series. (:
omg brooo for the last few months i had a problem with understating parameters and arguments, now i finally got it!! thank you so much
You make everything so easy to understand, I tried PeasFactory AlvinBlox and many other channels and this is the only one that actually makes me engaged and I learn from it. You explain it well and short. So you don’t waste time for 8 minutes you get straight into it and you actually explain extremely well. Thanks man.
I watched the vid without sound and with subtitles and when he says 'the dev king' the subtitles say 'the deaf king" LOL nice vids BTW
For some reason I think returning is the easiest.
Same.
Damn, this is probably the only concept outside of printing that I learned without having to practice after, thank you!
For ppl who are confused, basically parameters are like variables for example local function Stuff() In these () i want to find stuff. To save our time finding it using a function instead of using an variable to find it we use PARAMETERS so, to write an parameter we put the thing we want to find inside of the functions () and now the code would be local function stuff(stuff) Now, since we found it, I can use the parameter how much I want to use it (for me) now I would (for me) I would return "stuff" if successful. for example local function stuff(stuff) return true print(" returned"..tostring(stuff)) And as you see, I use stuff again cuz I was looking for stuff using an function. And yeah! Hope you understand.. and if you don't understand to tostring method.. I will create an video about tostring
thanks man this really helped a lot
Protect this man at all cost!!!!
bot?
Okay if you don't know, here's the conclusion, hope you'll like it :). :
Basically we're like making values like Hotdog, Ham in the video. then we call the function and add those two values together.
Hotdog, Ham = 3,2 and the "strings" are like words even tho they're numbers like "3" "79" "Test" Integers are numbers.
for those who dont understand basically, lets say u type a parameter in the brackets ok? then u type print(name of parameter) u type both of the parameters. then u call the function at the end and then add the value u want inside the bracket. basically the parameters u first made dont have any value but after u call the function u add a value to the parameter and then it prints the value u gave to the parameter(s) to the output. hope this helped.
God give this man some hotdogs...
He seems so sweet and optimistic and i LOVE IT he also tends to put hotdog in the scripts a lot lmao.
:O!
Hotdog is evolving! Hotdog involved into.. a... HotHamDog?
2:27
You can also return the sum of the two numbers by adding local sum before the equation. (Delete the print part if you do this)
so basically parameters are just variables that can have multiple values
Thank you TheDevKing, With all your videos till now, this is my Script :
local function myFunction1()
local MakeFunction = 76
print(MakeFunction*2)
end
myFunction1()
local a = 5
local function myFunction2(e, s)
local MyFavouriteNumber = 5
print (MyFavouriteNumber+a)
end
myFunction2(5, 19)
local function ReturnCommand()
print("This is my Whole script that I made")
-- Script
return("Wow, this is Advanced!")
end
local ReturnC = ReturnCommand()
print (ReturnC)
Wow easy understanding
Every one should teach like you
The way you explain is so easy! I have liked and subbed with notifications on!
When u were doing the variable why didn’t u do it like local then hot dog = 3 then ham = 2 why did u only do the ,
Alvinblox: hamburger
Devking: hotdog
I think he was hungry when he was making this and he cant stop thinking about food.
You can also add variables when you define the parameter for example:
local Number4 = 4
local function add(FirstNumber)
print(FirstNumber + 2)
end
add(Number4)
if youre wondering how it was able to print the function even though the print was AFTER calling the function, its because the print is part of the function. the function IS printing, so when you call the function, youre just printing it. (i was pretty confused on this for a while so i hope this helps anyone else)
its like Vars and each Var you giving it a different value of either a number or a word and it prints the results , btw is this playlist st ill good to watch in 2022 ?
Yes.
I never thought I would enjoy learning
What can we use these scripts for? I’m trying to make a anime game and this isn’t helping very much
You're my best teacher!
local function car(firstpart, secondpart, thirdpart)
print("car contains", firstpart, "and", secondpart, "and", thirdpart)
end
car("engine", "windows", "frame")
an example :)
If you guys still don't understand parameters, go watch alvin blox's tutorial about it on episode 3 on his beginner scripting tutorial guide on the timestamp: 5:02 as it is quite helpful.
You sure does love hotdogs xD btw nice tutorials i'm learning so much
What apps do u use if u are on school wifi?
The part i am confused about is how does any of this have to do with functions?
some other youtubers take 30 minutes to explain something
this man takes 5 minutes to explain the same thing and 10x easier
Buld really just said "deaf king"
bro's favourite word is hotdog LOL
Pov: returning from advanced series to parameters cause you dont understand how parameters work and cant make the tool damage people
In this case, hotdog was the variable that was holding the value "sweet" and the 2 next to sweet was used to give the variable hamburgers a value. So hotdog = "sweet" and hamburgers = 2
thank you
I usually use scratch and this kinda reminds me of custom blocks
Ok i might be to late but at 4:29 when he is wrtiing sweet cool awesome and others why doesnt it print 2?
In the parameter it says Hotdog, Ham but he only printed Hotdog in the function which when he called the function the parameter only recognized the Hotdog which equals Sweet. This is probably a bad explanation so you have any questions just ask.
Ham is 2, but it si not printed because he did not print ham, he printed hotdog
You cannot print 2 with the string for example you cannot print sauce with a number after and that’s why he only put print hotdog if you look closely if he put hotdog + ham it would cause an error hope this was helpful
I am not sure I will ever know how hard it is to learn parameters without DevKing. I learned from your video and it was SO easy to understand
I am surprised at how little confusion I have about all these, especially since I'm taking notes
I got through scope and returning with a good idea of what it is
I already know printing by now because it does the same thing in python
thanks for the idea of taking notes, idk why I didn't think of that earlier! I kept forgetting everything from the earlier videos but just rewatched them and took notes
I might be late xD, i've just started roblox studio yesterday and i've been doing animations and scripting, i dont understand what functions are for, what is Parameter, What scope and Return are for, what string is (which i think is the ("Hotdog") thing, please answer if any of you guys know or you DevKing
@SaadTahir-yx1gt Thats nice! There is also an advanced tutorial just so you know :D i kinda took a break since it just got boring and i lost motivation but im going to get back on my feet sooner or later
I get that when you talk abt functions and parameters or returns that you're using the print example to show what they do but people want to know how they can actually be applied when scripting a game not just printing words into output.
true I want to to know how you put in a script and not in print
so please correct me if im wrong but a practical example would be a fighting game, and use it to create a punch function. you could use the parameter to have, for example, a normal punch and a heavy punch?
yes that would work. but I would probably separate the functions for that.
My man mentioning his bros Hotdog and Hamburger in each episode👍
Pure dedication to his homies👌
for those who are confused an easier way to do this is by doing
local hotdog = 3
local ham = 2
now you've set the values into these variables/parameter's as you can see this is a bit easier
and you don't have to do add(3,2) -- this is a bit confusing
now you can do print(3,2) for those who are still having a problem this is how you do it
function add(hotdog, ham)
local hotdog = 3 -- btw this is what they mean by saying parameters' are just like variables because they are
local ham = 2
-- telling the function what to do
print(hotdog + ham)
end)
now do --
add() -- as you can see this is a bit easier then doing add(3,2)
What would happen if you printed hotdogs and ham
Will it turn into sweet2 when you add sweet and 2?
Only if 2 is also a string.
add("sweet", "2") would work
But if you used
add("sweet", 2) it would return an error, bc in a static typed language (u dont need to know this) as the case of lua, you can only add param/variables of the same type (string + string, integer + integer, etc)
if you dont understand paramaters are literally just variables that can be changed but can only be used inside the function its created in
Why would someone use returns
im still learning so correct me if im wrong but for people who dont understand Hotdog is the same as "local Hotdog = 3" and Ham is the same as "local Ham = 2" so when you print "print(Hotdog + Ham)" its like printing 3 + 2
0:38 just commenting so i remember where i am