|
| 02 Aug 2012 08:01 PM |
function KillPlayer(part) h = part.Parent:findFirstChild("Humanoid") if h ~= nil then h.Health = 0 end end script.Parent.Touched:connect(KillPlayer)
I understand function, but can someone dull down the defonition of argument/parameter so I can understand it?
Like on the first line I see the argument then I see it said again with the second line. Can someone break this kill brick down for me? |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 02 Aug 2012 08:05 PM |
An argument is the input and a parameter is the output. For instance;
function func (arg1,arg2) print(arg1,arg2) end
func("Hello,","World!")
>Hello, World!
In this case, the strings "Hello," and "World!" are arguments. arg1 and arg2 are the parameters. |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2012 08:13 PM |
Parameters, or arguments, are the INPUT part of the function.
Did you do "number machines" in elementary school (you put a number in, it gets put into a function, and it comes out) ? Well look at this:
function MyNumMachine(x) return 3*x + 1 end
print(MyNumMachine(3)) --Prints 10, because 3(3)+1 = 10 print(MyNumMachine(-1)) --Prints -2, because 3(-1)+1 = -2
The argument "part" in your case, is the Part that touched the connected function. When a function is connected to an event listener, the event gives the arguments, so "part" would stand for the part that touched, whenever it is used.
If you were to touch that brick, the part would be game.Workspace.theepicsamuri.LeftLeg or .RightLeg . In either case, the parent is you.
~This sig is false~
|
|
|
| Report Abuse |
|
|