R3PORT
|
  |
| Joined: 30 Nov 2012 |
| Total Posts: 2535 |
|
|
| 22 Nov 2013 11:53 PM |
function die() script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 end
script.Parent.MouseButton1Down:connect(die)
I am a beginner, and wanting to learn how everything works, or comes together bit by bit.
It is a GUI I know the function is to die when you click it.
|
|
|
| Report Abuse |
|
|
R3PORT
|
  |
| Joined: 30 Nov 2012 |
| Total Posts: 2535 |
|
|
| 23 Nov 2013 12:00 AM |
| The function is defined, and the second part is defining when to execute the function. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 23 Nov 2013 12:01 AM |
really simple,
script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
means a player
so....
player.Humanoid.Health = 0
then.. the connection line maens how to functoin is made!
so... MouseButton1Down means when you click the gui! |
|
|
| Report Abuse |
|
|
R3PORT
|
  |
| Joined: 30 Nov 2012 |
| Total Posts: 2535 |
|
|
| 23 Nov 2013 12:01 AM |
| But I am curious as to how the function is defined. |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2013 12:04 AM |
| http://wiki.roblox.com/index.php/Function |
|
|
| Report Abuse |
|
|
R3PORT
|
  |
| Joined: 30 Nov 2012 |
| Total Posts: 2535 |
|
|
| 23 Nov 2013 12:04 AM |
function die() script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 end
I guess I am wondering how that works |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 23 Nov 2013 12:05 AM |
I told you!
A functions name doesent matter
it can be
function KHADHSidnjirhvieohvioebviuebvieubvk ()
but the connection must be the same in ()
(KHADHSidnjirhvieohvioebviuebvieubvk) |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 23 Nov 2013 12:12 AM |
function die() script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 end
Ok so first of all, a function is a segment of code. You call a function by writing the function name (in this case, die) followed by a (), so like die() There is one exception to this rule. I will get to it later
The function will perform whatever comes after it until the "end".
script.Parent means the Parent property of the script. script.Parent.Parent means the Parent property of that, and so on until you get to Character. Character is a property of a Player, which is what script.Parent.Parent.Parent.Parent is. This gets the Character of the player, or the thing you control. :D
In Character, there should be a Humanoid object, which is what the Character.Humanoid does. An equivalent way of doing this is Character:findFirstChild("Humanoid") or Character["Humanoid"] A property of a Humanoid is Health, which is how When the Health reaches 0, the Character dies.
script.Parent.MouseButton1Down:connect(die) This means, that whenever the Button (which is the script's Parent) is Mouse Button 1 Downed (or, clicked), it will activate the function within the () after connect
in this case, the function is die. And this is the one exception to the die() rule. you dont need the () in this case.
I really like how you try to understand the script though. The forum needs more ppl like you. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 23 Nov 2013 12:14 AM |
| cool, wazap, you can script? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 23 Nov 2013 12:16 AM |
| Ya I can script.... but thats not the point I'm making here. I'm trying to explain it to him in a way that he can understand... |
|
|
| Report Abuse |
|
|