Ghost that follows player, after being in specific room

i want to program a ghost that follows the player after going to into a specific room.
For example the kitchen. The ghost then follows the player until the player reaches another specific room. For example the bathroom. After entering the bathroom the ghost vanishes and is back in the kitchen.

This is my code right now:

Ghost is a man. It is in Kitchen.

Every turn:
if the location of Ghost is not the location of the player:
let the way be the best route from the location of Ghost to the location of the player, using doors;
try Ghost going the way;
if player is in bathroom:
move Geist to kitchen.

I really appreciate any help you can provide

Try this.

The Ghost is a person in the Kitchen.

The ghost can be following. The ghost is not following.

Every turn:
    if the ghost is not following:
        if the location is the kitchen:
            say "A ghostly figure rises up from behind the refrigerator and begins to follow you!";
            move the ghost to the kitchen;
            now the ghost is following;
    otherwise if the location of the ghost is not the location of the player:
        if the location of the player is the bathroom:
            say "The ghost, seeing you enter the bathroom, shudders and disappears.";
            now the ghost is not following;
            move the ghost to the kitchen;
            say "The ghost follows you.";
            move the ghost to the location of the player.

This doesn’t use the route-finding, instead assuming that a ghost can pass through closed doors and such if necessary to follow the player anywhere.

Thanks for your help but Inform can’t compile this code into a working game because of tab indentations and i have no idea why. I tried to write it manually but the problem still appears. Sorry but im a total noob and cant figure it out by myself. Maybe someone has an idea? Here is what the compiler says:

Problem. The phrase or rule definition ‘now the ghost is following’ is written using tab indentations to show how its phrases are to be grouped together. But in that case the opening line needs to be on the left margin, not indented.

I made a typo and put a colon instead of a semicolon. Fixed.

Thanks! Now it is working like attended.