Actor Bounding Box Generation

I am trying to generate 2D bounding boxes for my characters in the level. I am using GetActorBounds to get the origin and extent points, calculate the eight corners of the 3D box and then project them onto 2D space before finding the max and min coordinates of those projected points. After that, I override the OnPaint function of the widget class to draw the bounding box using four straight lines. The script I am using is attached below:

However, only one of the characters get the bounding box despite me having used a foreach loop. This is shown below. (The white box)

How can I fix this? Any help is appreciated.