Sometime i had there just sticking some small metall parts. the magnet inside hold the debris and preventing the pins to connect
I should’ve been more specific. The problem is with the with the connecter that’s on the MacBook. I’m not sure what it’s called or how to refer to it.
what maerz said,
look closely at the port on the MacBook, the indent that runs around the connection points has magnets in it.
One time, there were some small metal filings on table that I didn't notice when I set my MacBook down, and one got sucked up to the connector, it nestled into that little grove, and prevented it from charging. It was really hard to see, took me a bit to figure out what it was. Get a flashlight and look closely. Or you can get a tooth pick or q-tip and run it around the outside of the connector on the Mac.
also make sure the pins on the cable are "bouncy" occasionally I've had a spring stick, and the pin didn't pop back up, pushing on it freed it up.
if there's nothing there, you can try resetting the SMC (system management controller) it handles the background power management. Or possibly also the PRAM or NVRAM
If you're experiencing weird glitches with your Mac, doing a reset of your MacBook or desktop Mac could help. Here's how to reset the NVRAM, PRAM, and SMC on either an Intel or M-Series Mac.
www.macworld.com