A heartwarming video message recorded for a child with autism by Doctor Who star Peter Capaldi gave the nine-year-old the courage to go to his grandmother’s funeral, his father has said.

In the video, Capaldi told Thomas Goodall, whose grandmother had recently died, that “sometimes sad things happen to us” and that he was on his side.

“When he said ‘sometimes sad things happen’, it was as though he was mentioning it (the bereavement) without mentioning it,” said his father Ross Goodall.

“Thomas only sees black and white – there is no grey area – and he has taken it to mean that you can be happy, even though sad things happen.

“That was when he decided that he wanted to go to the funeral. Up until then, he didn’t want anything to do with it but he was even comforting his sister. He was a different child. Normally, anything out of his comfort zone comes with consequences,” he told the Guardian.

Thomas, who is an avid Doctor Who fan and particularly liked the 11th Doctor, played by Matt Smith, wrote to Capaldi in early October wishing him luck in his new role.

Capaldi responded by letter soon after, thanking him and wrote a separate note to his father with advice on how to arrange a tour of the set and promising to send a video message to Thomas.

The video that Peter Capaldi sent to Thomas Goodall, who has been a fan of Doctor Who since he was around two years old.

That message arrived by email three weeks after the family’s subsequent bereavement. “I am assuming Peter Capaldi knew Thomas had lost his nan but the timing was just pot-luck,” Ross Goodall said.

“It was the first time he had smiled since his nan passed away. The only communication we had got until then was when he got upset and got angry.”

In the video, which Ross Goodall later posted on YouTube, Capaldi – in character – said: “Thank you very much for your letter. I really enjoyed getting it.

“Because you see, when Clara and I are travelling around in time and space, sometimes bad things happen to us.

“And you know what, Thomas? Sometimes sad things happen to us too. So, it’s nice to know that there’s somebody like you out there who’s on our side. And you should know that we’re on your side too.

“So you look after yourself, and take care, and be happy.”

Thomas has been a fan of Doctor Who since he was around two years old, his father said. “He wears his hair like Matt Smith and, on non-school uniform days, he dresses like him.”

The letter from Capaldi that preceeded the video message has now been framed and is hung in the family home, Thomas Goodall said, adding that his son now takes solace in it whenever he is upset.

“The comments on the video Thomas has been reading have really helped his confidence and made him feel a lot more comfortable.”