Parameter is the things inside () after a function call
Imagine a machine that performs a specific task: Cook food
Obviously when I say “food”, you can cook anything as long as it is food.
Cook an apple you get a cooked apple
Cook a chicken you get a cooked chicken
apple and chicken are parameters you feed into the machine that cooks food
cooked apple and cooked chicken are the things that the machine process our food into.
In code, it looks like this:
(For the sake of simplicity, the machine processes the name of the food instead of actual food )
function CookFood(foodName)
local cookedFood = "Cooked"..foodName-- Let's say there's some code to increase temperature of the machine
wait(10) -- Wait in seconds for the food to be cooked
return cookedFood
end
That’s basically what parameters are for, they change the output of a function based on input
Other examples are functions that damage a character, where you put in the damage amount and the character to damage as parameter.
there’s “return” in there, it tells the function to stop and
(any code below return in the same scope (the function in this case) will not run)
basically become the value it returns, like
local food = CookFood("Apple")
If you print
print("Today I cooked some "..food)
It will output
Today I cooked some Cooked Apple
The “..
” thingy tells the script to combine the string with the thing beside it, usually another string