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:

Previous Thread :: Next Thread 
FAMOUSMnM is not online. FAMOUSMnM
Joined: 15 Oct 2010
Total Posts: 21946
09 Dec 2012 12:16 AM
but i want to start again, gives me another thing to do on roblox
but, since i havn't in a while, i've lost most of my memory of it.

so, i am going to start off doing basic things, like messages and kill scripts

so would this work

function onTouched
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid =nil) then
humanoid.Health = 0
end
end

script.Parent.Touched:connect

sorry if it's really easy, but again, i have forgot how to script, so.
please help
Report Abuse
Dex1337 is not online. Dex1337
Joined: 01 Aug 2012
Total Posts: 185
09 Dec 2012 12:35 AM
function onTouch()
local script = script.Parent:findFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Health = 0
end

script.Parent.Touched:connect(onTouch)
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
09 Dec 2012 12:38 AM
No, that would not work. You are missing a parenthesis (which is not really needed), and you missed another = sign, when using the if statement. You also called your function wrong, it should be [Object].[Event]:connect([Function Name]). You also didn't include an open & closed parenthesis after your function. Nor an argument.

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ www.youtube.com/watch?v=N2GVu0A-vC4&feature=youtu.be
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
09 Dec 2012 12:39 AM

This is a more efficient way of doing it using an anonymous function:

script.Parent:Touched:connect(function (part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end

But on your part, it would look like this:

function Touch(part)
local humanoid = part.Parent:findFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end

script.Parent:Touched:connect(Touch)

You do however have the general idea of it.

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ www.youtube.com/watch?v=N2GVu0A-vC4&feature=youtu.be

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ www.youtube.com/watch?v=N2GVu0A-vC4&feature=youtu.be
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Dec 2012 12:40 AM
function onTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Health = 0
end
end

script.Parent.Touched:connect(onTouched)

There
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Dec 2012 12:41 AM
"This is a more efficient way of doing it using an anonymous function:"

Not really. Using an anonymous function doesn't make it really efficient, it's just a shorter way of writing it. It's not efficient or at least, by not a lot. You shouldn't focus on this. Premature Optimization is the root of all evil.

Report Abuse
FAMOUSMnM is not online. FAMOUSMnM
Joined: 15 Oct 2010
Total Posts: 21946
09 Dec 2012 12:43 AM
thank you @ everyone
Report Abuse
zorganBuilds is not online. zorganBuilds
Joined: 12 Oct 2012
Total Posts: 992
15 Dec 2012 09:19 PM
[ Content Deleted ]
Report Abuse
lordOspirits is not online. lordOspirits
Joined: 14 Dec 2012
Total Posts: 803
15 Dec 2012 09:33 PM
^
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