Is it possible to find models, then parts which are parents of those models via GetChildren?

Hi there,

I’m trying to create a PIS system (which is basically a information screen on a UK train or station). The train I’m going to make will include several models each of them called ‘SCREEN_’ than the ID number (i.e the nearest screen to the cab would be ONE, and the one nearest to the back would be NINE, if the train was nine carriages long). I would like to know, however, if GetChildren picks up a model and its parents? I’m doing this because the screens on the models are in a complex tree, as shown on the image below. I’d like to know if this works as I would like to change the text on my screen depending on if a part is touched with a certain value. If it does, how do I script it so it does that?Cheers.

GetDescendants() gets all children, and the children’s children, and the children’s children’s children, etc. Basically recursively getting all instances under the specified instance. I think this is what you wanted, or?

If your tree looked like this:

* Item 1
* -> Item 2
* ---> Item 2.1
* -> Item 3
* ---> Item 3.1
* -> Item 4
* ---> Item 4.1

and you did Item1:GetDescendants(), you would get all the children under it (even Item 2.1, Item 3.1, and Item 4.1).

4 Likes

Yeah, but I’d like to change the values for all models. i.e, if I change TextLabel under the parent DEST, and there are four identical models of the PIDS, each with the same tree, how would I code it because I’m honestly so confused? The variable name I’m going for is NextStations which is equal to ‘nill’ in my code.
image

You should consider switching the architecture. Could you please tell me why you are going to update all the other textlabels when one of them does?

1 Like

So basically, the System will be grouped in with the train. There are two detectors: one detector is located on the track and has a specific Value depending on what the next station is, so lets say the next station is called Essex Road, and that detector is just before Essex Road, so when the train runs over it aka the part on the train touches the part on the track, it switches the text to the Value on the part which is on the track and has the value of ‘Essex Road’.