I want a function that can call itself inside of it.
I’ve tried a few things and nothing seems to work, it just returns nil on the output each time.
Heres an example:
local hello = function()
print('hello')
hello()
return
end
hello()
I want a function that can call itself inside of it.
I’ve tried a few things and nothing seems to work, it just returns nil on the output each time.
Heres an example:
local hello = function()
print('hello')
hello()
return
end
hello()
If youre going for a recursive function, this code could help out. It will call itself 10 times, before terminating the function.
local function hello(counter)
print("hello")
counter = counter + 1
if counter < 10 then
hello(counter)
end
end
hello(0)
I figured out that it was because i was using “local hello = function” and not local function hello(). I’m not sure why thats a thing.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.