Tokolur
|
  |
| Joined: 10 Jan 2013 |
| Total Posts: 37 |
|
|
| 18 Jan 2013 04:24 PM |
Game.Workspace.Tokolur.Torso:Destroy()
This works, But i want to put it in a block and have it kill any player that touches it. What do i need to add? |
|
|
| Report Abuse |
|
|
noone334
|
  |
| Joined: 02 Aug 2011 |
| Total Posts: 2454 |
|
|
| 18 Jan 2013 04:53 PM |
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then h.Health = 0 end end script.Parent.Touched:connect(onTouched)
--Make sure this script is inside the block |
|
|
| Report Abuse |
|
|
Tokolur
|
  |
| Joined: 10 Jan 2013 |
| Total Posts: 37 |
|
| |
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 19 Jan 2013 09:49 AM |
Why don't people use anonymous functions!
Anyways the two end's, end the function and the if statement. Usually you'll know you need an end is there's a little tick next to a line, but not always. |
|
|
| Report Abuse |
|
|
TacoBowls
|
  |
| Joined: 02 Mar 2009 |
| Total Posts: 112 |
|
|
| 19 Jan 2013 09:59 AM |
Heres the script noone334 posted, but I'll add comments incase you wanted to know what all of it does:
function onTouched(part) -- Function that executes the next script when something (the brick) is touched.
local h = part.Parent:findFirstChild("Humanoid") -- Creates a variable named "h" and makes its value the humanoid of what touched that brick. if h~=nil then -- Checks if the person is still in the game h.Health = 0 -- Sets the persons health to 0. end -- As Azarth said, these two ends end the function and the if statement. end script.Parent.Touched:connect(onTouched) -- Closes our function.
As I said above, this is the script noone334 posted. |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 10:01 AM |
I only use anonymous functions when I need to use anonymous functions...
:/
Like connecting one of six random effects to randomly generated parts.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
Tokolur
|
  |
| Joined: 10 Jan 2013 |
| Total Posts: 37 |
|
| |
|
|
| 19 Jan 2013 11:53 AM |
| All the people on scripting are so much nicer than on Roblox Talk. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2013 12:10 PM |
@midnight Your face isn't nicer than Roblox Talk. Just kidding man, your statement is so true. It's because it's the learners and listeners who spend their time here. Roblox Talk is filled with mentally younger individuals who forget they are talking to real people, and take advantage of the fact that they are not face-to-face with a person. ANYWAY: SunTzu, I agree, declaring functions and then calling them is much more clean to me, even if it's longer. I'm perfectly capable of using anonymous functions, but I avoid them, because they just look like a mess. |
|
|
| Report Abuse |
|
|
lordsheen
|
  |
| Joined: 24 Oct 2008 |
| Total Posts: 608 |
|
|
| 19 Jan 2013 01:30 PM |
| script.Parent.Touched:connect(function(part) local human=part.Parent:findFirstChild("Humanoid") if human~=nil then human.Health=0 end end) |
|
|
| Report Abuse |
|
|