Chosen Solution

my laptop freezes whenever am charging it but when unplugged it works fine

My first thought would be that there is a short in the laptop jack or the charger however it could also be over heating since usually power options will adjust to a higher state when charger is connected. You can try changing the settings for “high power” in the power options setting to reflect the battery settings used when running on battery alone then plug in your charger and see if it still freezes if so it is most likely the charger.