How do i get my enemy to chase my main character?

im doing a pacman like game but im stuck on how im suppose to make the ghosts start running away if pac eats a power pellet. Also how would i make the ghosts suddenly vulnerable to pac after he eats the power pellet? helpp

please tell me how to do it because it kind of a major prta of my game