Typewriter effect repeating

Hello there! I have been making a subtitle system in roblox. The subtitle part of the script works, however, I added a typewriter effect to make the text appear “cooler”. This again works but I’m having a problem with it. Whenever it finishes writing the text out, it repeats its self again. I have been trying for a while now to fix this but it’s no use with my rusty lua skills.

--Example code
local textlabel = script.Parent:WaitForChild("Subtitle")

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

while true do
    local subtitleID = game.StarterGui.AttributesHandler.SubtitlesHandler:GetAttribute("subtitleID")
	
	local textcontent = " "

    if subtitleID == 0 then
		textcontent = " "
	end

	if subtitleID == 1 then
		textcontent = "Example subtitle"
	end
    
    typewrite(textlabel,textcontent)

    wait()
end

Yes I do know that it is in a while true do loop, however, with my knowledge there is no way for it to have to not be.

NOTES:

The script gets the subtitleID from an attribute and if possible I would like it to stay that way.

Thanks in advance if anyone knows a solution.
Tangy

I believe roblox added a type writer object a week ago or so. Try looking at that for a simplified way to go about it:))

Can’t find anything on it. If you know of some resources could you link them please?

Did you look at this?