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: Killing Script

Previous Thread :: Next Thread 
Tokolur is not online. 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 is not online. 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 is not online. Tokolur
Joined: 10 Jan 2013
Total Posts: 37
19 Jan 2013 09:48 AM
what does:

end
end

do?
Report Abuse
Azarth is not online. 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 is not online. 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 is not online. 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 is not online. Tokolur
Joined: 10 Jan 2013
Total Posts: 37
19 Jan 2013 11:39 AM
Ok Thanks Guys!
Report Abuse
midnightdemise778 is not online. midnightdemise778
Joined: 11 Feb 2012
Total Posts: 8057
19 Jan 2013 11:53 AM
All the people on scripting are so much nicer than on Roblox Talk.
Report Abuse
1MangoMan0 is not online. 1MangoMan0
Joined: 28 Sep 2010
Total Posts: 1596
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 is not online. 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
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