Bones not scaling with model?

code

I have a mesh part with bones. I need to keep the bones scaled with the mesh part, while also allowing size change on the Z axis.

In the first part of the video, this is done no problem using the scaling tool. However, when you try to set the scale manually using properties, or if you try to set it using a script, the bones do not scale properly.

I need to set the Z scale using a script, because the part’s Z size is dependent on how far your opponent is away from you (this is for an ability).

Can anyone help me out? Maybe explain why this happens? Maybe there is a way to simulate the scaling tool in a live session?