I’m so sorry you are going through this. 5 is quite a good long life for a chameleon.

do you have any photos of him currently and his enclosure ( lights included). Maybe his humidity is off, have you had a change of seasons or has his uvb bulb been changed recently? Poor guy, just trying to think out of the box being it could be so many things at 5. Has he ad a fecal test? Sometimes parasites cause those symptoms as well.