I have a problem with understanding Arguements and Parameters. I already know a decent amount of scripting, but the only part I didn’t fully understand the use of, is Parameters and Arguements.
``` --Example (taken from a peasfactory scripting tutorial)
function add(var1, var2) answer = (var1 + var2) print(answer) end
add(5,10)
--Alternate Solution local var1 = 5 local var2 = 10
function add() print (var1 + var2) end
add()
```
Can someone give me an example that relies on Arguements and Parameters? Because, I’m confused. Oh, and try adding some comments so that I can understand.
Parameters are a function's input variables. When you call the function, you pass what will be arguments.
Arguments are a function's input values.
When you call a function, you pass these in between parentheses
```lua local function divide(num1, num2) return num1/num2; --// divide the numbers received end
print(divide(4, 2)); --> 2 ```
Parameters are useful when your function needs to take anything. In my divide
function, any numbers can go in between the parentheses. It doesn't have to be a specific number.
Finally, I do not recommend PeasFactory
or alvinbloxx
or any of those youtubers because his videos are outdated and he gives misinformation most of the time. I recommend PiL (Programming in Lua) and maybe the roblox wiki if you really wanted to.