Weight painting models with loose parts
Automatic weighting gets confused when a mesh is not continuous, non-manifold, with intersections and so on ...

You could separate all your loose parts (P, in edit mode), do the automatic weights on the base mesh, then manually parent the loose parts with their respective bones, then join all the meshes, selecting the base mesh as last (Active) and pressing Ctrl J.