Massachusetts prosecutors say a troubled teen took his own life after exchanging texts with a fellow student who egged him on to do it.

Prosecutors from the Bristol County District Attorney’s Office said Michelle Carter, 18, encouraged 18-year-old Conrad Roy to kill himself last July. They charged her with involuntary manslaughter Friday, a charge punishable by up to 20 years in prison, MyFoxBoston reported.

Roy drove his truck to K-Mart in Fairhaven, near New Bedford, with a gas generator and took his own life. The cause was carbon monoxide poisoning.

The station cited court papers as alleging that at the K-Mart, Roy got out of his truck and texted Carter. He told her he wasn’t sure he should go through with it.

“Get back in,” she texted back, according to the court papers.

The station said that after Roy’s death, Carter posted messages on social media saying that she missed him. In September she organized “Homers for Conrad,” a fundraiser to raise awareness about suicide.

“Instead of attempting to assist him or notify school officials, a counselor, a family member, anyone, Miss Carter is alleged to have strongly influenced his decision to take his own life, encouraged him to commit suicide on multiple occasions and guided him through the process, including the engage of activities that ultimately led to his death,” Gregg Miliote, a spokesman for the Bristol County DA, told the station.

Carter was released on $2,500 bond and ordered to stay off social media after a court appearance. Her next court date is April 17.

Her attorney Joseph Cataldo said it was unfortunate Roy killed himself “but it is outrageous for the Bristol County District Attorney’s Office to now criminalize this situation.”

Roy, of Mattapoisett, graduated high school a month before his suicide. Carter, of Plainville, graduates high school in June.

Roy’s grandmother is heartbroken.

“If she really loved him as she said she did why didn’t she try and prevent him not to,” Janice Roy told MyFoxBoston