I've never truly understood what differentiates a local function from a normal function, and when it is appropriate to use one or the other.
COMMUNITY QUESTION
What is the purpose of a local function?
1 answer
There's not much of a difference. All the local statement does is declare a local variable. local variables do not carry between functions, for statements and if statements.
If i were to run this code it would print false since the if statement it changes c locally.
local c = false
if true then
local c = true
end
print(c)
The same thing with functions if i ran this code it would output hi.
local c = function()
print("hi")
end
if true then
local c = function()
print("bye")
end
end
c()
If i were to run this code it would output bye since the if statement doesn't declare it locally.
oof = function()
print("hi")
end
if true then
oof = function()
print("bye")
end
end
oof()
-ThisIsAnAccount255
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please search in google or in Scripting Helpers Search Bar before questioning a question. The answer to your question can be found here: https://scriptinghelpers.org/questions/16395/what-are-the-differences-between-local-function-and-function