Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"Typing" UI scheme? (Need help, should be simple)

For example, someone typing a sentence using a Keyboard. I'm trying to mimic that but I've never done it before, this is my best guess.

Also, to put it in perspective, think about an RPG and when the NPC's talk to you.

This script is for an NPC GUI. When you press a "Chat" button it will greet you with the following script using a 'typing' scheme.

script.Parent.MouseButton1Down:connect(function()
    local text = script.Parent.Parent.Parent.npcChat.ImageLabel.TextLabel.Text
    local txtTable = {
        "t",
        "e",
        "s",
        "t",       
    }
    text = table.concat(txtTable, ' ')
end)

1 answer

✓ Accepted answer

Do you mean something like instead of the text appearing all at once it appears by each individual letter? Lucky for you, I think I made that script a long time ago and still have it. Tadaa

function characterChatspellOut(text)
	local textlen = string.len(text)
	for i = 1, textlen do
		print(string.sub(text, 1, i))
		if textlen >= 20 then
			wait(0.04)
		elseif textlen >= 15 then
			wait(0.05)
		elseif textlen >= 10 then
			wait(0.07)
		else
			wait(.1)
		end
	end
end

I'm going to explain it a little just in case you are curious.

Base script

function characterChatspellOut(text)
	local textlen = string.len(text)
	for i = 1, textlen do
		print(string.sub(text, 1, i))
		wait(0.05)
	end
end

The different between the script above and the first one is that sometimes when I have really long dialogue I prefer to speed it up. To do this, in the first script I say if the text length(textlen) is greater then 20 characters then(and then I make the wait smaller) Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.