What is the advantage of using this:
local function onPlayerAdded(player)
print(player.Name)
end
game.Players.PlayerAdded:Connect(function(onPlayerAdded)
Instead of this:
game.Players.PlayerAdded:Connect(function(player)
print(player.Name)
end)
It could also apply to this:
local function doWhileLoop()
print("a")
end
while wait() do
doWhileLoop()
end
Instead of this:
while wait() do
print("a")
end
So basically, why should I consider using functions instead of just writing under the thread?

1 comment
Thanks for the explanation, I genuinely tought I was making my game laggier by not using functions, but looks like I'm fine.