Tim Allen has said he was told to stick to the script when voicing Buzz Lightyear in Toy Story 4 as his adlibs were creating extra work for the animators.

The actor has voiced Buzz since Toy Story was released in 1995 and he recalled some of his improvised lines that made it into the films, while noting that he was discouraged from going off book for the upcoming final instalment.

"The classic to me was when I would ad lib. It's not like Robin [Williams] when he did Aladdin. When I would ad lib, it's not a happy moment for the animators," Allen told CinemaBlend.

"They'll go, 'Oh god, that was funny, that was funny...' which means they have to go back and reanimate it. Mrs Nesbitt, when I got drunk on Darjeeling tea and I'm holding my own arm in my hands... and I said, 'Is the hat too much?' It was hysterical and they left that in.

"Also, when Woody goes, 'You are a toy!' and I said, 'You are a sad, strange little man and you have my pity.' The animators are going, 'Oh, damn, that's funnier than what we wrote.'

"Early on, they'd give it to me. Lately they just say, 'Tim, read the script'."

Allen added that he has gotten protective over his character, sometimes arguing with the writers about whether or not Buzz would say certain things.

"You honour the process," he said. "When these guys let you just go and find who Buzz is. I will say, the last of this is I've gotten to a point where - I can't believe I'm saying this - I'll go, 'Buzz wouldn't say that.'

"I mean, I'm telling the people who created this character and I get kind of huffy. 'Buzz doesn't get that excited and he won't say that! I'm gonna get some sliced pineapple'."

Toy Story 4 is released on June 21.