|
| 06 Sep 2010 06:29 PM |
I am new to scripting this is my second script so don't laugh
function OnTouched(Water) local human = part.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = 0 end end
script.Parent.Touched:connect(OnTouched)
I want it to kill you when you touch the brick named Water |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2010 06:30 PM |
function OnTouched(part) local human = part.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = 0 end end
script.Parent.Touched:connect(OnTouched)
The function OnTouched(Water) was incorrect, the (Water) part basically names the touched brick. |
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Sep 2010 06:36 PM |
I tried what you said it still doesn't work I'm not sure if this changes anythink but the brik is walkthroughable |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2010 06:45 PM |
It shouldn't... here's my script, not sure if there are any errors.
function OnTouched(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then hit.Parent:findFirstChild("Humanoid").Health = 0 end end
script.Parent.Touched:connect(OnTouched) |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2010 06:48 PM |
| Oh right, found the problem, in findFirstChild:("Humanoid") you weren't supposed to capitalize find, LUA's really picky about capitalization. |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
|
| 06 Sep 2010 06:49 PM |
@Above heres a little more efficent i made a little similar
script.Parent.Touched:connect(function(Water) if Water.Parent:FindFirstChild("Humanoid") ~= nil then Water.Parent:FindFirstChild("Humanoid").Health = 0 end end) |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2010 06:54 PM |
Thanks to everyone that helped me with my second script it is working now |
|
|
| Report Abuse |
|
|
OBF
|
  |
| Joined: 29 Sep 2009 |
| Total Posts: 10709 |
|
|
| 06 Sep 2010 06:56 PM |
NU! Not mch is more efficient than this:
script.Parent.Touched:connect(function(H) pcall(function() H.Parent.Humanoid:TakeDamage(100) end) end) |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
|
| 06 Sep 2010 06:59 PM |
| Lol OBF of course that's more efficent. |
|
|
| Report Abuse |
|
|
naknak
|
  |
| Joined: 30 Jun 2008 |
| Total Posts: 350 |
|
| |
|
|
| 06 Sep 2010 07:38 PM |
@ninga
Actually, both :findFirstChild and :FindFirstChild work. Same with :getChildren and :GetChildren. I actually prefer capitalizing the first word as well. |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
|
| 06 Sep 2010 07:42 PM |
| I never said that, and i prefer FindFirstChild more then findFirstChild |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2010 07:48 PM |
| Darn, I never knew that >.> |
|
|
| Report Abuse |
|
|
naknak
|
  |
| Joined: 30 Jun 2008 |
| Total Posts: 350 |
|
|
| 06 Sep 2010 07:55 PM |
| The last time I tried to capitalize "find" it errored |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
|
| 07 Sep 2010 12:25 AM |
| Lol FindFirstChild i think works better, but they both work the same i guess sooo yea. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2010 12:27 AM |
| wait for function() you need something in the ()`s? |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
|
| 07 Sep 2010 12:28 AM |
| I only bumped this to get to 1.5 k posts :) |
|
|
| Report Abuse |
|
|
Xuriel
|
  |
| Joined: 14 Jun 2010 |
| Total Posts: 1615 |
|
|
| 07 Sep 2010 12:29 AM |
I never use GetChildren()
I use children()
Same with GetService(), I use service()
Works with all functions that begin with get (Built in functions). |
|
|
| Report Abuse |
|
|
ninga95
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 5026 |
|
| |
|
|
| 07 Sep 2010 12:45 AM |
@ninga Sorry...I meant to direct my message @uknown :P
I prefer just writing GetChildren and GetService. |
|
|
| Report Abuse |
|
|