my macbook has been experiencing a strange charging issue
I've owned this macbook pro for 5 years, and I have used the same USB-C power cable adapter for all 5 years. Recently my macbook wasnt charging because the USB-C cable was fried, so I replaced the cable and not the power adapter. Now it does charge again for my macbook, but with a catch: when my macbook isn't on, it charges without any issues and to 100% capacity; but when it is on, it doesn't charge fully and sometimes it fluctuates between charging up and not charging (that is, for example, it goes from 50% to 52% and then suddenly loses power and drops to 49% or lower). What could be the issue here? Should I replace the power cable or should I get my power cable outlet on my macbook pro checked up?
MacBook, macOS 10.14