"That's the best story I've ever heard in my life," Jimmy Fallon told Rami Malek of his memory with Robin Williams on set of the third Night at the Museum

Advertisement

Rami Malek will always remember a humbling, live-in-the-moment lesson he unexpectedly learned from Robin Williams while filming what would become the late actor's final live-action movie before his death.

Malek, 39, opened up on The Tonight Show Wednesday about the touching moment between himself and Williams as they were filming Night at the Museum: Secret of the Tomb, the third and final film in the Night at the Museum franchise, after Williams noticed cast and crew were distracted by technology in a way he didn't quite connect with.

"We're shooting at the British Museum at night and we have the place all to ourselves," began The Little Things star, 39. "And Robin — you could tell something was happening with him. He would go on these riffs every once in a while and light up the world and you'd be like, 'Oh my God. Who are you?' And then dip back down into this other place."

According to Malek, Williams would "see us all on our phones and devices and he'd be like, 'What happened to [face-to-face communication]?' "

"And so I see him veer off and he walks off alone, and he's just kind of staring at this massive rock in the British Museum. And I'm like, 'Oh, man. What's going on with him? Is he all right?' " the Oscar winner continued.

Never miss a story — sign up for PEOPLE's free daily newsletter to stay up-to-date on the best of what PEOPLE has to offer, from juicy celebrity news to compelling human interest stories.

Night At The Museum - Secret Of The Tomb - 2014
Patrick Gallagher, Robin Williams, Ben Stiller and Rami Malek in Night at the Museum: Secret of the Tomb
| Credit: Kerry Brown/20th Century Fox/Kobal/Shutterstock
Rami Malek; Robin Williams
Rami Malek (L); Robin Williams
| Credit: Frazer Harrison/Getty Images; Jason LaVeris/FilmMagic

He soon realized Williams was reflecting on how far communication has come, and taking advantage of an opportunity to be in the presence of one of the most important relics in human history to appreciate the moment.

"I walk up to kind of say, 'Is everything okay?' And he looks at me, just kind of slightly over the shoulder, and he goes, 'How often do you get to be alone with the Rosetta Stone?' " Malek explained.

"That's the best story I've ever heard in my life," host Jimmy Fallon told him, joking in addition, "And you were like, 'Apparently not enough because I just interrupted you.' "

Williams' final film was the third Museum installment, in which he reprised his role of President Theodore Roosevelt. Filming wrapped in May 2014, three months before Williams died by suicide that August at age 63.

Robin Williams
Robin Williams in 2013
| Credit: Robin Marchant/Getty Images

Want to get the biggest stories from PEOPLE every weekday? Subscribe to our new podcast, PEOPLE Every Day, to get the essential celebrity, entertainment and human interest news stories Monday through Friday. Get a taste of the podcast below.

RELATED VIDEO: Jumanji Child Star Bradley Pierce Recalls How Robin Williams Stood Up to Producers for Him

In Robin's Wish, a recent documentary focused on the final months of Williams' life, Secret of the Tomb director Shawn Levy says Williams was having a hard time on set. The actor had been struggling with diffuse Lewy body dementia (LBD) for months, which causes fluctuations in mental status, hallucinations and impairment of motor function.

"I would say a month into the shoot, it was clear to me — it was clear to all of us on that set — that something was going on with Robin," Levy said in a clip from the documentary shared by Entertainment Tonight. "We saw that Robin was struggling in a way that he hadn't before to remember lines and to combine the right words with the performance."

"When Robin would call me at 10 at night, at two in the morning, at four in the morning, saying, 'Is it usable? Is any of this usable? Do I suck? What's going on?,' I would reassure him. I said, 'You are still you. I know it. The world knows it. You just need to remember that,' " the director added.

"My faith in him never left, but I saw his morale crumbling," Levy said. "I saw a guy who wasn't himself and that was unforgivable."