Gave someone $500 that was originally for college...

So I have been seeing this guy and I am about to go to college. I managed to save up over $1000 for college. So long story short, this guy told me he was going through an extremely rough time. Was about to be homeless. He didn’t ask for it, but I gave him $500 to help him out and he said he would pay it back by August for sure.

Well today he found out that he has to either pay $487 or go to jail for 60 days because of something that happened 4 years ago.

If things don’t work out with me and him, do you think he would still pay me back? If he doesn’t, could I take him to court over this?

I feel dumb but I love him and I want to help him.

Edit: I have the messages of him saying he will pay it back by August, and we’re going to write out an agreement and sign our names and stuff so is that good enough? And yes I know what he used my money on for those asking.