Hello, I’ve been learning scripting again and I constantly become confused with parameters. How do I know what parameter to use and when to use them. Would I just look at the documentation to see what parameters belong in that function or do I make them up?
Thank you! 
1 Like
Parameters are passed values that are inputted from a function/method call.
function foo(parameter)
print(parameter)
end
function bar(a, b, c)
-- parameters are also in relative "order"
print(a, b, c)
end
foo() -- nil
foo(1) -- 1
foo("Hello World!") -- Hello World!
bar(1, 2, 3) -- 1 2 3
bar("A", 8, nil) -- A, 8, nil
For already existing methods, you simply include them in the function call’s parenthesis. Or if you’re hooking to events that always return some form of parameter:
game:GetService("Players").PlayerAdded:Connect(function(player)
-- Anonymous function, but the parameters are fixed
end)
To decide when to use a parameter, simply know when to pass the value.
1 Like