Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the use of Arguements and Parameters?

Asked by 5 years ago

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.

0
Don't forget to accept my answer if it helps. User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Parameters

Parameters are a function's input variables. When you call the function, you pass what will be arguments.


Arguments

Arguments are a function's input values.

When you call a function, you pass these in between parentheses

Function using these:

```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.

0
Can you elaborate more on the "Parameters are useful when your functions need to take anything" part? Maybe give examples that include objects on Roblox. Deson00 4 — 5y
Ad

Answer this question