How to tell which character is next?

I want to make a realistic typewriting system, here’s my script.

	local message = "Detail, Detail2, Detail3, Detail......."
	for i = 1, #message do
		script.Parent.Type.PlaybackSpeed = math.random(5,15)/10
		script.Parent.Type:Play()
		if i+1 == "," or i+1 == "." then
			script.Parent.TextLabel.Text = string.sub(message, 1, i)
			wait(1)
		else
			script.Parent.TextLabel.Text = string.sub(message, 1, i)
			wait(.1)
		end
	end	

But i cant seem to get it to figure out if the next character is a comma or period
any way of doing this?

You are comparing a number to a character, so it will always be false.
I think you meant to do this:

if message[i+1] == "," or message[i+1] == "." then

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.