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

How to fix my script for GUI "typing" effect? [Answered]

Asked by 10 years ago

I want the letters to form 1 by 1 to make seem as if it's being typed. I stumbled upon an error with my script showing numbers in-between each. I feel like I should know how to fix it but I'm stuck. Here's my script (Not Local) :

SP = script.Parent



while true do
    SP.Text = "H"..wait(0.1).. "e"..wait(0.1).."l"..wait(0.1).."l"..wait(0.1).."o"
    wait(2)
end

Thank you(This script is not finished, I'll be having more words show that's why it's so small). Oh, it is set as ScreenGui>Frame>TextLabel>script

0
I know it's possible, For example Khols admin script using shouts, their words are typed on to the screen. alphawolvess 1784 — 10y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Your problem here is that you are concatenating the return of wait, which happens to be a number.

Your script also isn't very scaleable, since you're trying to write all the numbers by hand. Here's a more easily extendable form, using some string manipulation:

local sp = script.Parent

function guiType(word)
    if string.len(word) <= 1 then
        sp.Text = word
        return
    end

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

local words = {"Hello.", "How are you?"}
while true do
    guiType(words[1])
    wait(2)
    guiType(words[2])
    wait(2)
end
0
Thank you. alphawolvess 1784 — 10y
Ad

Answer this question