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: touched event for all children

Previous Thread :: Next Thread 
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
23 Dec 2013 01:39 PM
I would like to have an event that fires every time a child of a model is touched.
The number of children is constantly changing.
I would prefer to use one script and not have a seperate script for each child.
Report Abuse
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
23 Dec 2013 01:43 PM
Could I do this?

Model.ChildAdded:connect(function(child)
Child.Touched:connect(function(otherPart)
print("Child Touched")
end)
end)
Report Abuse
janthran is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
23 Dec 2013 01:44 PM
function reroll()
object=model:GetChildren()
end
reroll()
object.ChildAdded:connect(reroll)
object.ChildRemoved:connect(reroll)
for i,v in pairs(object) do
v.Touched:connect(yourfunctionhere)
end
Report Abuse
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
23 Dec 2013 01:50 PM
That dosn't seem to work
Report Abuse
janthran is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
23 Dec 2013 01:51 PM
it should
you replaced yourfunctionnamehere with your function right
Report Abuse
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
23 Dec 2013 02:03 PM
yes. I found the problem though..

function reroll()
object=model
object2=object:GetChildren()
end
reroll()
object.ChildAdded:connect(reroll)
object.ChildRemoved:connect(reroll)
for i,v in pairs(object2) do
v.Touched:connect(yourfunctionhere)
end
Report Abuse
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
23 Dec 2013 02:05 PM
I need a way to get the part that touched the child.
Report Abuse
janthran is not online. janthran
Joined: 15 May 2009
Total Posts: 17429
23 Dec 2013 02:13 PM
function touched(part)
print(part)
end
Report Abuse
JetCrusherTorpedo is not online. JetCrusherTorpedo
Joined: 13 Feb 2012
Total Posts: 218
24 Dec 2013 10:46 AM
It is not working in online mode.
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