Why are you checking if it is func_tracktrain when you’re CLEARLY looping through a table that ONLY contains func_tracktrain?
Also, you should do some research and attempt to LEARN the language, not just copypaste some functions. HUDPaint ALWAYS updates except for when the console is open, your entities health is the part that isn’t updating.
ADDITIONALLY, .toscreen is not part of the function you’re trying to get it out of.
I was changing around this function a good bit, I left in a redundancy that checked for func_tracktrain twice. whoops.
I initially thought that the hudpaint hook didn’t call more than once, but it was the variables that weren’t being networked to the client that made me believe that it wasn’t being called more than once.
The entities health was updating fine, the variables weren’t being networked to the client correctly. I fixed this using ent:GetDTInt(0) with some help from .\Shadow}
well, I used the same function to draw the text, but I had to set the health inside the entity using ent:SetDTInt(0) because using the method ent.Health() wouldn’t network the health properly to the client.
It was my mistake to think that the problem was HUDPaint hook not calling more than once and not the variable being networked to the client properly, but I got it all now.