Changing the scale of the parent messes up the children

I have a parent object that uses a script which adds several children objects to it. However if I try to modify the parent’s transform.localScale in the script the scale properties of the children are messed and I have no idea why.

Here’s the first scenario that produces correct results:

1.Instantiate the parent object.
2.Change its position.
3.Call a method that creates the children and sets their parent.
4.Get correct results.

However if I modify the parent’s scale like shown below the children’s scale is set to (0,0,0):

1.Instantiate the parent object.
2.Change its position.
3.Change its scale.
4.Call a method that creates the children and sets their parent.
5.All of the children have scale set to (0,0,0).
6.Get incorrect results.

Can someone explain to me what I’m doing wrong?

Ah, an old problem. Attached an empty game object and attached it to the parent, take the child and parent it to the new empty game object.

Make sure the EmptyGameObject has 0,0,0 for scale, and this should solve your issue.

Children inherit transform data from their parents, so this is why it messes it up so to speak,

Hope this helps.

(Will convert this to an answer as soon as it lets me.)