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

Is there any way how to simplify text showing up?

Asked by 6 years ago

Hey, just wanna ask, is there any way how to simplify this ? Just so I dont have to use

        script.Parent.Chat1.Text.Text = "H"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "He"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hel"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hell"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, "
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, h"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, ho"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how c"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how ca"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I h"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I he"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I hel"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I help"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I help y"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I help yo"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I help you"
        wait(0.1)
        script.Parent.Chat1.Text.Text = "Hello, how can I help you?"

everytime ? Thanks!

0
I think there is if you manage to use string manipulation and for loops abnotaddable 920 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local stringg = "a string!" --the string we want to do letter by letter
local stringt = {} --the table we will use

for i = 1,string.len(stringg) do --loop through the string
    local toinsert = string.sub(stringg, i, i) --get that specific letter of the string
    table.insert(stringt, toinsert) --insert it into the table
end

local newstring = "" --the string we will change

for i = 1,#stringt do --loop through the table
    newstring = newstring .. stringt[i] --set the string as the current string and the extra letter
    print(newstring) --print the new string
    --button.text = newstring -- optional
    wait(0.1) --wait to the next change
end

I hope this will help you!
EDIT(use this method instead):

local stringg = "a string!" --the string we want to do letter by letter
newstring = "" --the new string (not neccessery if just setting text)
for i = 1, #stringg do --loop through the string
    newstring = string.sub(stringg, 1, i) --make the new string 1 longer letter by letter
        --button.text = newstring -- optional
    print(newstring)
    wait(0.1) --wait to do next change
end

or

local stringg = "a string!" --the string we want to do letter by letter
for i = 1, #stringg do --loop through the string
    button.text = string.sub(stringg, 1, i) --make the new string 1 longer letter by letter
    wait(0.1) --wait to do next change
end
--this method is ALOT shorter lol
0
Oh, I did not have the page reloaded, your works too aswell, but mine is bit simpler. Nice work anyways! ItzBlazik 9 — 6y
0
wow wow too complicated to make a table why not just do one simple for loop hiimgoodpack 2009 — 6y
0
^ did not think of other method that itz used! :c xd abnotaddable 920 — 6y
Ad
Log in to vote
1
Answered by 6 years ago

Thanks! I finally found out, for others, check this,

local text = "Sample text, put here."  --The text you want to be printed
for i = 1, #text do --Repeats something from 1 to number of letters in local text
    script.Parent.TextLabel.Text = string.sub(text, 1, i) --This is the main part which adds letter every 0.05 seconds
    wait(0.05) --Set as you want
end --You probably know what is this

-- Made by itzblazik
0
definelty alot simpler - did not think of it this way! abnotaddable 920 — 6y

Answer this question