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

How to fix Stack Overflow on a simple script?

Asked by 8 years ago

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.

local scroll = script.Parent.Parent:WaitForChild("Main")
script.Parent.FocusLost:connect(function(enterPressed)
    if enterPressed then
        Echo(script.Parent.Text)

    end
end)



function Echo(word)
    Echo(script.Parent.Text)
    for i=1,string.len(word) do
        scroll.Text=string.sub(word,1,i)
        wait(.05)
    end

    wait(2)
    scroll.Text=""
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."

1 answer

Log in to vote
1
Answered by 8 years ago

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

0
Derp. I'm really stupid. Thanks for the solution man! httpOmqCxpcake 70 — 8y
Ad

Answer this question