How to do an good typewritter effect

i wanted to do a typewritter effect but i think Is kinda A Mess, is there any good practice instead of doing this? yes, i searched in youtube, but i dont know if they are using a correct format

while task.wait(0.1) do
   text.Text = "H"
 task.wait(0.1)
   text.Text = "HE"
 task.wait(0.1)
   text.Text = "HEL"
 task.wait(0.1)
   text.Text = "HELL"
 task.wait(0.1)
   text.Text = "HELLO" 
   task.wait(1)
end
1 Like

Use string.sub to get a substring of some whole string, then print that.

local someString = "Hello, my name is!"

for i = 1, string.len(someString) do
	print(string.sub(someString, 1, i))
	task.wait(0.1)
end
3 Likes

Roblox has already created an article for a typewriter, so here’s the link. Hope this helped you find a solution to your problem.

2 Likes

There is a better way of doing this, but I find the following easier
l

local text = "hello"
for i = 1,#text do -- // iterate through the number of characters in the string, i being the character
    print(string.sub(text,1,i)) -- // string.sub returns a string but characters from the first parameter to the second, in this case 1 to i.
    wait(.01)
end
2 Likes

This would work on another “objects” like Pointlights,surfacelights?, instead of waiting every second and increasing his brightness value?

Yes.

local surfaceLight = workspace.SurfaceLight

repeat
	task.wait(0.1)
	surfaceLight.Brightness += 0.1
until surfaceLight.Brightness >= 1
1 Like

Use tweens for increasing that instead of looping, you can tween most properties like brightness