I've seen some scripts with Variable=function()what difference does it have between function Name()?
✓ ANSWER ACCEPTED
What's the Difference between "function Event()" and "Event=function()"?
1 answer
✓ Accepted answer
Your question has been adequately answered already, but to remove it from the Unanswered sort category, I'm going to a write a full answer.
There is absolutely no difference between:
function funcName() end
and:
funcName = function() end
In fact, the former is actually just syntactic sugar for the latter!
When using Tables, either form works except for once case:
local tab = {}
function tab.funcName() end --valid
tab.funcName2 = function() end --valid
tab["funcName3"] = function() end --valid (Also lets you make functions with non-string identifiers)
function tab["funcName4"]() end --INVALID
--This is the only case where the sugar doesn't work. I'm not sure *why* it doesn't work, but I've tested it before and it provably does not work.
1 comment
0
Cool! Thanks adark!
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
There isn't really any difference, however, setting the function up as a Variable in a Table allows you to use it in, well, a table (Example: local Table = {Var = function() print("Yay!") end)}), and you can call it still (Example: Table.Var()).
ohh...So basically it both can be used?
Yes, it's just that the Variable version has a few more advantages, but can sometimes error when not used correctly.
It's just the style that people write code in.
ikr
function Name() is the preferred method i believe, so use it whenever possible.