|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 23 Dec 2013 02:05 PM |
| I need a way to get the part that touched the child. |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 23 Dec 2013 02:13 PM |
function touched(part) print(part) end |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 10:46 AM |
| It is not working in online mode. |
|
|
| Report Abuse |
|
|