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

Manipulating tables for an NPC-dialog GUI?

	local textPath = script.Parent
	local text = ""
    local textlen = string.len(text)

    for i = 1, textlen do
        textPath.Text = (string.sub(text, 1, i))
			script.Parent.Sound:Play()
            wait(0.04)
    end

I'm making a GUI that has a character 'speak' text, but I want the character to say the multiple sets of text in a single function without needing a messy script.

Basically, I want my local text variable to have a table containing different texts and manipulating said table to say certain phrases.

In this case, it's just going to be something like this:

local text = {
"T";
"E";
"S";
"T";
}

I need this manipulative variable to be intertwined into my current script, but I don't know how to. Also, if a kind gentleman/lady would tell me how to order how the text is "played-through", I would be greatful.

Ultimately, I'm asking for somebody to modify my script to the way I like it, I apologize if this sounds like a request; I have no real idea on how to do this.

1 comment

0

Are you trying to type out the letters one by one..?

2 answers

function phrase1()
    local phrase = ("Hello.")
end

function phrase2()
    local phrase = ("How are you?")
end

local phrase = phrase1() --starts with phrase1

for i=1,string.len(phrase)do 
wait(0.1)
p.Text = string.sub(word,1,i)
end

phrase2() --convert to phrase two

for i=1,string.len(phrase)do 
wait(0.1)
p.Text = string.sub(word,1,i)
end

--rinse and repeat

2 comments

0

Well, what I did for mine which was easiest for me, instead of your function phrase() I put the whole code in each function. So phrase1 would already have the spelling script in it, as well as the others. And then when the time came in the script to use a chat phrase, I would just call it and your done

0

GENIUSSSSSSSSSSSSSSSSSSSS

function chat1()
	local word = ("Hello.")
	for i=1,string.len(word)do wait(0.1)
	p.Text = string.sub(word,1,i)
	end
end

The above script will take whatever your local word is, and then spell it out one letter at a time. Hope that's what you wanted.

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