Help with making typewrite text speed faster

I’ve been trying to make a NPC dialogue system, and I’ve pretty much finished, and I’m trying to increase the typewrite speed.
(Sorry, I’m unable to attach a video)

This is my typewrite function currently:

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

When I decrease the speed, even to wait(), it doesn’t change. However, when I increase it to, say, wait(3) it shows very clearly. Can someone help me with making it faster, or is there no way?

1 Like

Maybe you could try

game:GetService("RunService").Stepped:Wait()

So should I replace the wait with that? (Would it cause any lag, or something)

Well I think you’re referring that as it is running on the server. If you’re worrying about lag I think it is best to find a way to make the dialogue system local. But yes, you should replace the wait() with that line.

1 Like

I would like to add, the smallest amount of time you can wait() for is 0.03 seconds (1/30th of a second), but even then it’s not very precise and can end up being 0.04.
RunServices.Stepped:Wait() seems to wait 0.0166666667 seconds on average (1/60th of a second).

Edit:
If you want to see for yourself, wait() actually returns the amount of time it waits for, and so does RunService.Stepped:Wait().
So you can do print(wait(WaitTime)) to see how long it really waits for, or set a variable to how long it waits for in order to calculate the average wait time. local waitedTime = wait(0.1)

1 Like