Weight loss roller coaster

Options
I have struggled with my weight a lot over the years. I never thought about it much when I was younger and when I got to high school I was weighing 245lbs and started working at Walmart. Not knowing what I wanted to do with my life I decided to join the Marine Corps but I had to lose a lot of weight so I began running and going to the gym and over the months I was working out and changing up my diet I went from 245 to 199 lbs while at boot camp I lost 17 more pounds and left boot camp at 182. But while going to my schools I slowly grading my weight back to the point that advisers wanted to check my bank statements and asked how many times I ate out a week or how many candy bars and sodas I drank a week. and then hitting the fleet my weight went back up cause I lost my motivation to keep working twice a day and eating healthy and gained my weight back. While on my first deployment I lost alittle bit of weight going from 210 to 196. And I felt good about myself for losing the weight but then I feel off the Wagon again I tried losing the weight again on my second deployment but I didn’t lose it like I wanted too and have struggled with my weight loss and my weight has gone up and down. Now that I’m out of the Marine Corps i looked at myself in the mirror and I didn’t like what I saw at all I weigh 238lbs and I want to get back to my boot camp weight of 182lbs. If there is anyone that can offer tips or help motivate me to reach my goal I would greatly appreciate it.