Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Manipulating tables for an NPC-dialog GUI?

Asked by 9 years ago
    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.

0
Are you trying to type out the letters one by one..? Goulstem 8144 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
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
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 Xoqex 75 — 9y
0
GENIUSSSSSSSSSSSSSSSSSSSS konichiwah1337 233 — 9y
Ad
Log in to vote
-2
Answered by
Xoqex 75
9 years ago
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.

Answer this question