How can i call a function in the same Module?

How can a call a function which is in the same modulescript from where i am calling it?

1 Like

The function is stored inside the table that you’re returning from your module script. You can call the function by referencing to the function in the table itself. This can change depending upon what data you’re returning from your module script. For example, if you’re returning a function (instead of a table of functions) from the module script, then you can call the function straight away.

local Module = {}

function Module.Foo()
    print("Hello world!")
end

function Module.Bar()
    -- some code
    -- calling the function in the same module.
    Module.Foo()
end

return Module
6 Likes