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

Is there any way how to simplify text showing up?

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!

1 comment

0

I think there is if you manage to use string manipulation and for loops

2 answers

✓ Accepted answer
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

3 comments

0

Oh, I did not have the page reloaded, your works too aswell, but mine is bit simpler. Nice work anyways!

0

wow wow too complicated to make a table why not just do one simple for loop

0

^ did not think of other method that itz used! :c xd

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

1 comment

0

definelty alot simpler - did not think of it this way!

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