What is the difference between the two ways of writing functions

Hello! I have been wondering for awhile now, what is the difference between the way these two functions are written, and why or why not is one used at certain times?

game.Workspace.somethingHappened:Connect(function()

--bla bla bla bla bla

end)



function somethingHappened()

--bla bla bla bla bla

end

game.Workspace.somethingHappened:Connect(somethingHappened)

I am just curious.

There is no difference in use except for the fact you can use the second one to establish multiple event connections to a single function instead of a single event connection to a single function.

1 Like

Is there one that is more recommended than the other? I like to use the second one more but I am not an expert scripter so I don’t know.

Nope there’s no significant difference in performance as far as I know and it’s all about preference. I use the first always unless I need the 2nd for multiple connection events.

1 Like