Hello. I am fairly new to scripting and am just testing things out. I ran across a tutorial on Parameters, but I still do not quite understand the concept of what Parameters are. May someone explain what they are and how they can be used?
Parameters are variables used for functions and events, for example:
function printx(parameter) print(parameter) end printx("hello world")
in this case, parameter is a variable, outta thin air, a variable. Its role in the code is to do something for the function.
for events, im gonna use touched
workspace.Part.Touched:Connect(function(PersonThatTouched) end)
in this case, the parameter is who touches it, think of the parameter as the event, what its telling you, it says "Touched" so the "PersonThatTouched" will be the body part of the player that touched the object
there is many things you can do with parameters, define local variables within functions, it can be very useful actually!
function check(value) if value == true then print('value is true') else print('value is false') end end check(true) check(false)
a parameter can be a string, number, bool, tables, I am also pretty sure if you setup your code right, objects can also be a parameter, well enjoy this long answer, if this helps, click the "Answer" button, thanks :D