murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
|
| 19 Jan 2013 01:16 PM |
I'm making a script that checks if a tree has fallen under a model. What I can't figure out is how to find index of value that is changed within the hits array. Since the function treehit is called upon a change in the array. All I want to know is how do I tell the program to bring up the value that has changed in the array.
If you can help me, Thank you so much.
local hits = {} local trees = script.Parent.Trees:GetChildren() --Path is correct for i = 1, #trees do hits[i] = trees[i].hit.Value end function treehit() for i = 1, #trees do hits[i] = trees[i].hit.Value end end
hits.Changed:connect(treehit) |
|
|
| Report Abuse |
|
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
| |
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
| |
|
sting4672
|
  |
| Joined: 29 Oct 2009 |
| Total Posts: 1396 |
|
| |
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
|
| 19 Jan 2013 02:17 PM |
| I mean, the real question is, Can i detect a change in a specific value of an array? |
|
|
| Report Abuse |
|
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
| |
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
| |
|
|
| 19 Jan 2013 08:05 PM |
I think you mean to make treehit run when a child in trees gets changed?
function treehit() for i = 1, #trees do hits[i] = trees[i].hit.Value end end
for _, tree in ipairs(script.Parent.Trees:GetChildren()) do tree.hit.Value.Changed:connect(treehit) end |
|
|
| Report Abuse |
|
|
murigun
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 433 |
|
|
| 21 Jan 2013 04:12 PM |
| Oh, thanks. That works, but I already fixed it. Thanks a lot though! |
|
|
| Report Abuse |
|
|