How to make an object move along with an object with a model animation

If you have the name of the bone, you can search for it and attach the window as a child of the bone. Eg: How to attach a weapon(Gun) to a character bone?