A SEX offender posed as a teenage boy to bombard what he thought was a 13-year-old girl with sickening sex messages.

But William Barr, 61, was actually having chats with an undercover policeman who had set up a social media account to catch sleazy predators.

The officer alerted colleagues after Barr hounded ‘her’ with dozens of creepy messages saying he wanted to have sex.

And it was Barr’s wife who answered the door of the Renfrew home they shared at the time when police arrived to arrest him.

Barr has now been placed on the Sex Offenders’ Register and could be jailed when he is sentenced later this month.

The details emerged when Barr, who has since fled to Blackpool, appeared in the dock at Paisley Sheriff Court to plead guilty over his sordid actions, which he committed in November last year.

Procurator fiscal depute David McDonald told the court the communication began after the policeman set up an account on the KIK messaging app, claiming to be a 13-year-old girl from Oxford.

Barr initially said he was “way too old” before claiming to be 19.

He then said he would “love” to send her a pic of himself but couldn’t, adding: “I could get in trouble because of ages.”

Barr said he wanted to ask the girl for a picture but was worried he’d “get into bother” if she did and it was discovered.

After the officer sent Barr an image which he believed was of the girl’s legs, he replied that it got him “excited” and that he liked girls in swimsuits.

Barr also said he wanted to be alone with the girl and perform sex acts on her.

He also asked for images of her cleavage, said he was “so horny” for her and suggested he would visit Oxford after being told that was where she was from.

The court was told his wife answered the door when officers went to detain him in March this year and, when cautioned and charged, he replied: “I’m bamboozled.”

Sheriff Tom McCartney called for background reports to be prepared ahead of sentencing, adjourned the case for that to be done and continued Barr’s bail.

Read all the latest from Renfrewshire and beyond