Which Methode Is More Optimized?

Greetings everyone today i have a simple question which of these two methods are more optimized :

local part = Instance.new("Part",game.Workspace)

local function onTouch(hit)
	print("Part Has Been Touched")
end

part.Touched:Connect(onTouch)

Or

local part = Instance.new("Part",game.Workspace)

part.Touched:Connect(function()
	print("Part Has Been Touched")
end)

Realistically there is no difference, they are the same connection method just different places where the function is placed in the script. This is just a matter of readability and preference.

2 Likes

I don’t think there really is much a difference, or the difference is so little that it makes nearly no impact to the game. Correct me if I’m wrong.

1 Like

There’s no difference at all. “On touch” connects the same as “function()”. They are both function connections

1 Like

Thanks to @desinied @Deb0rahAliWilliams and @Tubbes1 i just won’t use the first method because it’s kinda hard to read

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.