For short (<10 line) functions, I will usually use the second form. For longer things, I will separate them so it’s easier to read and modify in the future.
If the code is only used in one place, it doesn’t matter. Often times, a developer will use a named function in order to call it from more than one context, e.g. both an event handler, and something that can be explicitly called, which you can’t do with an anonymous function. An example such as you might have in a LocalScript waiting for the LocalPlayer’s character:
local function OnCharacterAdded(char)
-- your chracter added code
end
player.CharacterAdded:Connect(OnCharacterAdded) -- Handles all future character spawns
if player.Character then
OnCharacterAdded(player.Character) -- Direct call to handle already-spawned character
end
This way, you don’t have to copy-paste the block of code, and then possibly have a bug from changing one copy of the code and forgetting the other.