why my compyter shuts down suddnly when im playing video games as long as im charging it

Hi,

If it's shutting down by itself even if it's connected to it's charger then the problem is it's overheating. It's a safety feature of all laptops to shut down when it hits a certain temperature where it may cause more damage. Do start by cleaning the inside of your laptop making sure there's no dust or debris stopping the fans from spinning properly and apply a new thermal paste as well onto the GPU and CPU. If all these will not work do try another AC adapter that has the same voltage and see weather if your laptop will shut down by itself or not.