Stack overflow error

I got this error and it froze studio for a couple seconds, I thought it was an infinite loop but it’s not that. This is the error I got:

This is where it came from:

openFuncs.Stats = function()
	buttonSFX:Play()
	if statsDebounce == false then
		if upgradesOpen == true then
			openFuncs:Stats()
		end
		statsFrame:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"Out", "Linear",0.5)
		wait(0.5)
		scrollRoll(statsFrame)
		statsDebounce = true
	else
		scrollRoll(statsFrame,true)
		statsDebounce = false
		statsFrame:TweenPosition(UDim2.new(0.5, 0,1.5, 0),"Out", "Linear",0.5)
	end
end
4 Likes

Stack overflow exceptions usually occur in the case of a recursing function that never stops running.

And I think I can see why.

Assuming upgradesOpen is true to begin with, you’ll then call :Stats(), and this will continue to repeat and will actually never stop running.

Fix

Try setting statsDebounce to true if your condition if statsDebounce == false is true.

3 Likes

Oh alright I will check that out. Thank you

Oh yea oops I was running the wrong method that’s why.