|
| 08 Apr 2012 06:39 PM |
I know this script works:
local lava = script.Parent
function onTouch(Part)
local player = Part.Parent:findFirstChild("Humanoid")
if (player ~= nil) then player.Health = 0
end end
lava.Touched:connect(onTouch)
But I was wondering what the "Part" In "local player = Part.Parent:findFirstChild("Humanoid")" Is refering to, I'm trying to understand scripting a bit more, that's why I'm wondering. |
|
|
| Report Abuse |
|
|
XGojiraX
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 10 |
|
|
| 08 Apr 2012 06:47 PM |
| When the function 'OnTouch' is called, it sets the variable 'Part' to what ever is touched. Part.Parent:findFirstChild("Humanoid") is looking for a Humanoid in the same directory as the 'Part'. |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 08 Apr 2012 06:55 PM |
script.Parent.Touched:connect(function(part) if part.Parent:findFirstChild("Humanoid") then part.Parent:breakJoints() end end)
|
|
|
| Report Abuse |
|
|
Quovis
|
  |
| Joined: 24 Mar 2012 |
| Total Posts: 494 |
|
|
| 08 Apr 2012 06:55 PM |
| Part is the object that hits the lava. The parent of a leg is a character, then it finds a Humanoid. |
|
|
| Report Abuse |
|
|