I'll try to explain in the most simplest of examples.
you can only call local function after you declare it:
local function myfunction ()
end
myfunction()
it will not work if you try to call it before it's declared:
myfunction()
local function myfunction ()
end
however if the the local function is inside another function or local function.
you can only call that local function inside that function or local function:
local function firstfunction ()
local function secondfunction ()
end
secondfunction()
end
things like this will not work:
local function firstfunction ()
secondfunction()
local function secondfunction ()
end
end
or
local function firstfunction ()
local function secondfunction ()
end
end
secondfunction()
or
secondfunction()
local function firstfunction ()
local function secondfunction ()
end
end
Now, global function (functions without local)
You can call a global function anywhere as long as it is in the same script
secondfunction()
function firstfunction ()
local function secondfunction ()
end
end
or
local firstfunction ()
function secondfunction ()
end
end
secondfunction()
There might be things I said wrong, so check these if you want to learn more.
https://developer.roblox.com/en-us/articles/Variables
https://roblox.fandom.com/wiki/Function
https://developer.roblox.com/en-us/articles/Scope
2 comments
Thank you so much for you're answer!
Well explained. Thank you.