A boy used his knowledge of "stranger danger" to hide behind a tree when a woman tried to lure him into her car as he walked home in central west NSW, police say.

The six-year-old school student got off a bus on Landa Street, Lithgow, about 3.35pm yesterday and started to walk home, when he was approached by a woman in a silver hatchback.

The woman asked the boy to get in the car, but he ignored her and kept walking, police said.

Police said she began driving slowly next to him and again asked him to get in her car.

The boy hid behind a tree on the side of the road until the woman drove away.