Hi! I'm New to LUA! I've been playing around with FOR.
==[What does the script do?]== When I enter stuff on the TextBox, it slowly types it in the TextLabel.
Here's the object Tree https://gyazo.com/931c9ff84ad0eba39d17955f9b5a673f
Script in textbox.
01 | local scroll = script.Parent.Parent:WaitForChild( "Main" ) |
02 | script.Parent.FocusLost:connect( function (enterPressed) |
03 | if enterPressed then |
04 | Echo(script.Parent.Text) |
05 |
06 | end |
07 | end ) |
08 |
09 |
10 |
11 | function Echo(word) |
12 | Echo(script.Parent.Text) |
13 | for i = 1 ,string.len(word) do |
14 | scroll.Text = string.sub(word, 1 ,i) |
15 | wait(. 05 ) |
16 | end |
17 |
18 | wait( 2 ) |
19 | scroll.Text = "" |
20 | end |
It gives me: https://gyazo.com/c7429d99ab6ebb79ab897c63af8ad598 Stack Overflow. I never encounted this problem before, I have no idea how to fix it. @koolkid8099 told me "It's when a program tries to use more memory, than available."
Lua returns to output "stack overflow" usually when your trying to call a function from inside itself. To resolve this issue, remove line 12 of your code. Your attempting to call a function from inside itself which will trigger nothing but error. But in general,a stack overflow is a common problem faced when using stacks. It occurs when the stack grows larger than the area it has been allocated. However, there is no need to worry about a stack overflow since Lua is dynamic and will allocate more memory to the stack as needed, depending on what your doing
~~This is my perspective of it, Hope i helped