How to solve this function problem:

Hello guys. I have 1 problem with functions:

local function Holder()
    local function Test1()
        if Check == false then Test2() end
    end
    local function Test2()
        if Check == false then Test1() end
    end
end

This functions are inside a function, and they should call eachother, if check fails. But Test1 don’t sees Test2. Can I fix this?

local function Holder()
    local Test2;
    local function Test1()
        if Check == false then Test2() end
    end
    function Test2()
        if Check == false then Test1() end
    end
end

Or the equivalent and maybe clearer what’s happening:

local function Holder()
    local Test2 = nil
    local function Test1()
        if Check == false then Test2() end
    end
    Test2 = function()
        if Check == false then Test1() end
    end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.