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

How to make this easier or simpler?

I was making a script that will display a sentence letter by letter but then I figured that there could be something easier to do this. Is there any easier or simpler way?

		script.Parent.Parent.Story.Text="O"
		wait(0.15)
		script.Parent.Parent.Story.Text="On"
		wait(0.15)
		script.Parent.Parent.Story.Text="One"
		wait(0.15)
		script.Parent.Parent.Story.Text="One n"
		wait(0.15)
		script.Parent.Parent.Story.Text="One ni"
		wait(0.15)
		script.Parent.Parent.Story.Text="One nig"
		wait(0.15)
		script.Parent.Parent.Story.Text="One nigh"
		wait(0.15)
		script.Parent.Parent.Story.Text="One night"
		wait(0.15)
end)

1 comment

0

there is an easier way, give me a sec to write out

2 answers

✓ Accepted answer
local string = "One night"

for i=1, string:len() do
	script.Parent.Parent.Story.Text = string:sub(1, i)
	wait(0.15)
end

string:len() finds the length of the string. The script loops until it has spelled out the entire string.

local Text="One night"

for i=1,#Text do
	script.Parent.Parent.Story.Text=Text:sub(1,i)
	wait(.15)
end

2 comments

0

On line 4, you have an extra parenthesis.

0

Oh oops, I edited it because before it said 'print(Text:sub(1,i))'

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