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

What are Parameters used for? How can I use them?

Asked by
Ak_aii 4
4 years ago

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?

1 answer

Log in to vote
2
Answered by 4 years ago

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

0
cool explanation starmaq 1290 — 4y
0
Helped a lot. Thank you. Ak_aii 4 — 4y
0
welcome :) greatneil80 2647 — 4y
Ad

Answer this question