Typewriter Text Effect help

Ello, I am developing an overhead where it has a text label that uses the typewriter effect to list a second group a player is in, the finished product is this:


note the secondary text is not there

Anyways, it is not working. My code has it only typing the first letter. Please help!
So yeah its not doing the typewriter effect and only showing the first letter.
a9a01bafc4aab4b361e3d4db3ad11f5d

local textLabel = script.CoreUI.OverheadGui.SecondaryTitle.secMsg
wait(1)

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

while true do
	typewrite(textLabel,"Error Bloodline",0.07)
	wait(5)
end

Any help would be great :heart:

It seems that you’re setting the template secMsg text instead of the object in the function parameter. Maybe try replacing that with ‘object’ (which is the textLabel, not the template)?

object.Text = string.sub(text,1,i)
Full Script
local textLabel = script.CoreUI.OverheadGui.SecondaryTitle.secMsg
wait(1)

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

while true do
	typewrite(textLabel,"Error Bloodline",0.07)
	wait(5)
end

Just tried it, sadly same result.

Is this the full script, or can I see the full script?

No it is not, thats just the specific part of the typewriter managment.

@CoconutError
Maybe you have your TextLabel MaxVisibleGraphemes set to less than the length of your input string? MaxVisibleGraphemes limit the amount of characters that can be displayed in a TextLabel. Try changing that property to your input text length and it should work.

Full Script
local textLabel = script.CoreUI.OverheadGui.SecondaryTitle.secMsg
wait(1)

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

while true do
	typewrite(textLabel,"Error Bloodline",0.07)
	wait(5)
end

In alternative thinking, you could be changing, first the text, then looping MaxVisibleGraphemes to the text length instead of changing the text, and it would work the same way.

Full Script
local textLabel = script.CoreUI.OverheadGui.SecondaryTitle.secMsg

wait(1)

local function typewrite(object,text,length)
	object.MaxVisibleGraphemes = 0
	object.Text = text
	for i = 1,#text,1 do
		object.MaxVisibleGraphemes = i
		wait(length)
	end
end

while true do
	typewrite(textLabel,"Error Bloodline",0.07)
	wait(5)
end

No there is not another script changing text for that specific label.

I recommend you use MaxVisibleGraphemes to achieve this effect. Essentially what it does is limits the amount of characters of the text shown on the text label. So instead of using String.sub() you can just do something like

for i = 0,#text,1 do
    textLabel.MaxVisibleGraphemes = i
end

The documentation actually has a typewriter effect example so I recommend you have a look at that.

Okay. I’ll check it out thanks.

Try using the typewrite() function outside of the while loop and see if it makes a difference?

Nope, that also did not work. It’s odd because I made something using a typewriter effect a few weeks ago and it worked.