During a visit to Hearts FC's Tynecastle Stadium on Thursday, Prince William spoke with men involved in The Changing Room - an initiative set up by the Scottish Association for Mental Health (SAMH) in partnership with football teams across Scotland.
The project aims to bring men together through football to tackle mental health.
Big Hearts Community Trust, the charity associated with Hearts, is part of the programme.
William joined participants Pher Nicolson and Kristian Wilson in a "walk and talk" around the stadium before meeting some of the others involved.
When discussing what had brought them to the programme, one participant became emotional. He said: "Sorry, I'm getting emotional here," to which William replied: "It's good to get emotional, that's what we're here for."
The duke has long been an advocate for discussing mental health and breaking down stigma.
Mr Wilson lost his brother to suicide last year.
Speaking of his chat with William, he said: "It went well and we had a really great conversation.
"Everyone was just talking about their own experiences and he was just really involved and really engaged.
"One of the things we talked about was, how do we get people to open up rather than bury all of their feelings, and one of the conversations we had was about peer support.
"When you have a high profile like the duke, that's going to encourage other organisations."
Mr Nicolson said: "He was very proud of the guys for making a difference and sharing so openly and how that makes a difference, because it allows other guys to step forward and seek support. He recognised that the guys were leaders in that respect."
William also met with representatives from Hearts, who presented him with club strips with his children's names on after he was heard saying they do not yet have a Scottish team.
The duke told the team: "Here's hoping they have success."
Billy Watson, chief executive of SAMH, said: "We were delighted to welcome the Duke of Cambridge to The Changing Room today. It is a programme that we are immensely proud of and that we know has made a difference to so many men's lives.
"The Changing Room shows us that while men sometimes struggle to talk about how they feel, when the environment is right and when men feel supported, they are not just good at talking, they are actually great at it.
"It has been fantastic to see Scottish football really embrace the importance of mental health and wellbeing.
"The Changing Room would not be possible without the brilliant collaborative approach of our partners - Movember Foundation, the Scottish Government, SPFL Trust, and football club charities and trusts across Scotland."
Craig Wilson, Big Hearts Community Trust general manager, said: "It was a great honour to welcome the Duke of Cambridge to Big Hearts and talk about our charity's work harnessing the power of football to help people take care of their mental health and wellbeing."
William's visit to Tynecastle concludes a two-day tour of Scotland as part of the Queen's Platinum Jubilee celebrations.