Okay, so I have been watching peasfactory. And, I am learning about Parameters and Arguments. I wanna tell what I think they are, and please feel free to fix/ give more info needed. Gonna be very basic cause I am new.
Basically, when you call a function so
test() -- what is in the "()" is a variable. And that variable can only be used inside of the particular function it is in. However to call it you need to give it a value. The value is the argument. Don't know much about argument, sept its the value of the variable, and I think it is assigned outside the function?? Or can it be assigned inside, or out?? THANKS.
Arguments are the variables created by functions. Parameters are the definitions of those variables. In methods like FindFirstChild(), you only have to type in the Instance parameter (and, if you want, the boolean recursive parameter). Example:
if game.Workspace:FindFirstChild("Part") ~= nil then print("part found") end
"Part", the string put in as the parameter to the Instance argument, defines Instance as a Part in the Workspace. All methods require you to fill in just a parameter.
Functions
Functions are a bit different from methods. Functions require you (if you want) to give it an argument AND fill in a parameter for that argument. Example:
function Roblox(oof) print(oof) end Roblox("oof")
The tricky thing with parameters to function arguments is that they can be any value possible. In the function Roblox(), the argument "oof" was defined by the parameter "oof" (a string). Most parameters define the arguments outside the functions.
Exceptions?
The most talked-about exception to being defined outside the function is defining it inside the function. This is not possible. You can spread the argument around the function however you want, but if you want a parameter for it that parameter must be outside the function. Example:
function Round(num, addend) -- You can have more than one argument return math.floor(num + addend) end Round(6.5, 0.5)
This function uses the two arguments it produced and sets them as nil until the parameters are set for them. In this case, we are rounding 6.5 to 7 by "tricking" math.floor(). If you have any questions, please ask them.
Thanks, MCAndRobloxUnited