No, it was scripted, but he thought that the line would not be perceived as funny because it was too creepy for a grown man to say that to a small boy.
It WAS creepy! That's why it was so funny!
Recently, I had someone ask me: "Have you ever seen a ....."
What it was is actually irrelevant. But, he asked it with exactly the same inflection and a voice similar to Peter Graves.
And it creeped me out. I couldn't say "no" and get away fast enough.
Good. Thanks.