generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Can someone help me understand arguments?

Previous Thread :: Next Thread 
TheEpicSamuri is not online. TheEpicSamuri
Joined: 04 Dec 2011
Total Posts: 1343
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 is not online. 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
Mathfreak231 is not online. Mathfreak231
Joined: 21 Jun 2010
Total Posts: 5311
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image