Mark Inglis, who is 17 this month, referred to the killings when he tweeted that he may go into school with a gun and "start taking bodies".
Stirling Sheriff Court was told the tweet was spotted by John Crozier, whose five-year-old daughter Emma was one of 16 children shot dead by Thomas Hamilton at Dunblane Primary School.
Lindsey Brooks, prosecuting, said: "Mr Crozier was alarmed by the comments and concerned about public safety. He contacted the police at 11pm. At 20 past four in the morning police attended at the accused's home address as there were concerns he might have a firearm."
Inglis, of Sherwood Road, Glenboig, near Coatbridge, North Lanarkshire, pled guilty to threatening and abusive conduct.
Defence lawyer Andy Gallen said Inglis had been drinking with friends before going home and sending the message.
He said: "He didn't weigh up the significance of what he was saying. He didn't intend to cause to offence and alarm, but he now recognises it would very clearly have caused fear and alarm. He presents today in a very contrite frame of mind."
Mr Gallen said Inglis was at school, due to sit Highers, intended to go to university, and had never been in trouble with the law before.
Sheriff William Gilchrist said: "I am going to proceed on the basis that this was stupidity, and you're only 16 and you've never been in trouble before."
He deferred sentence for good behaviour until September.