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 this?

Previous Thread :: Next Thread 
R3PORT is not online. 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 is not online. 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 is not online. 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 is not online. 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
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
23 Nov 2013 12:04 AM
http://wiki.roblox.com/index.php/Function
Report Abuse
R3PORT is not online. 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 is not online. 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 is not online. 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 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
23 Nov 2013 12:14 AM
cool, wazap, you can script?
Report Abuse
wazap is not online. 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
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