A man has pleaded guilty to sending sexual messages to a 13-year-old girl who was ­actually an undercover cop.

Kenneth Martin, 43, admitted attempting to communicate with a child for the purposes of obtaining sexual gratification or of humiliating, distressing or alarming a person who he believed to be a child.

The offence took place between November 19 and 30, 2018 from Martin’s home in Bearsden.

Fiscal depute Kevin Doherty told Dumbarton Sheriff Court how police are proactive in monitoring activity online and have specially trained undercover officers. One, known only as Officer X, pretended to be a child named Jay and had chats with Martin after posting a profile on the web portal Lycos.

READ MORE: Glasgow pervert had 700 indecent images of children as young as eight

At 12.57am on November 19, the cop went online and was contacted by a user named “cocabloc”. It was “flirtatious from the outset” despite the officer identifying themselves as 13.

He made reference to the fact he loved the Welsh accent and told the officer: “So sexy, although probs shouldn’t say that since you’re only 13 lol.

“I’m older hun – 36 – old enough to be your dad.”

The chat included repeated references to him being aroused while communicating with someone he believed to be 13, and to sharing a bed with the child.

The last communication was on November 30 and then police launched an investigation to identify the other individual, who also used the username “Irishfella” and the Kik messenger app.

READ MORE: Glasgow 'lethal weapon' driver jailed for eight years after mowing down teenager

When traced, police went to Martin’s Bearsden home while he was still out. He then turned up holding a plastic box with electronic devices, including a laptop. That was later analysed and the chats found with the two user names.

Martin “spoke freely and admitted he was the person who had been engaging in chat”, the court heard.

Mr Doherty added: “He did appear to admit he had engaged in conversation with a 13-year-old.”

Defence solicitor Judith Reid said her client had been in full-time employment until the offence came to light.

Sheriff William Gallacher said he needed background reports on Martin, a first offender, and deferred sentence until November 28. He was put on the sex offenders register and given bail in the interim.