Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is the use of Arguements and Parameters?

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.

1 comment

0

Don't forget to accept my answer if it helps.

1 answer

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:

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.

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.