How could I make this typewriter-animated sign more compact in code?

Hello! I’ve been working on a typewriter sign, I got it to work, but I was wondering how could make this code smaller. Right now I feel it’s a bit bulkier than it could be, and decided this would be a good way to learn more about scripting.


Here is what it looks like in game if you’re curious
image

Wanted to say thank you for helping if you do in advance.

You could try using variables like:

local label= script.Parent.SurfaceGui.TextLabel

and you could use a for loop and string.sub.

Here you go.

local function Typewrite(object, text)
	for i = 1,#text do
		object.Text = string.sub(text,5,i)
		wait(1)
	end
end