When I try
01 | local texts = { |
02 | "TestMessage 1" , |
03 | "TestMessage 2" |
04 | } |
05 |
06 | wait( 8 ) |
07 | for i = 1 ,#texts do |
08 | script.Parent.Text = string.sub(texts, 1 ,i) |
09 | wait( 0.1 ) |
10 | end |
it won't work while it work before I added the second one.
1 | local text = "test message" |
2 |
3 | wait( 8 ) |
4 | for i = 1 ,#text do |
5 | script.Parent.Text = string.sub(text, 1 ,i) |
6 | wait( 0.1 ) |
7 | end |
Is there any way to fix?
Firstly, I noticed you we're using an Array of Text Strings so before, we can do anything. We will need to require those messages by using a simple method:
1 | for i,v in pairs (Sayings) do -- Gathering all the Messages typed in the Array. |
We will also need to determine how fast the message is typed by using:
1 | for i = 1 , #v.Text do -- Determines Typed Amount. |
Now, we can begin on the UI stuff and making the message type out. We can achieve this by using:
1 | script.Parent.Text = string.sub(v.Text, 1 , i) -- Type the Message Out |
2 | wait( 0 ) -- This will determine the speed of the text, you can change this to whatever you want. |
That is all that sorted and your final code should look like this:
01 | local UI = script.Parent |
02 | local debounce = false |
03 | local Sayings = { |
04 | { Text = "Hello, I am a test message 1" } , |
05 | { Text = "Hello, I am a test message 2" } , |
06 | { Text = "Hello, I am a test message 3" } , |
07 | } |
08 |
09 | wait( 5 ) -- Wait before Starting |
10 | for i,v in pairs (Sayings) do -- Gathering all the Messages typed in the Array. |
11 | wait( 3 ) -- How long to Wait Before Messages |
12 | for i = 1 , #v.Text do -- Determines Typed Amount. |
13 | script.Parent.Text = string.sub(v.Text, 1 , i) -- Type the Message Out |
14 | wait( 0 ) -- This will determine the speed of the text, you can change this to whatever you want. |
15 | end |
16 | end |
I hope this helped you out.