They’re both the same. :Connect() connects an event to a function to run your code when it fires. In the first method, you are connecting Touched to a new function, and then running the code inside.
In the second method, partTouched is already defined and you’re connecting Touched to it.
I think it’s really up to your preference which way you use it.
You could use the second one if you want to make one function for multiple events, so for example
local function myEvent()
-- do stuff
end
script.Parent.Event1.OnServerEvent:Connect(myEvent)
script.Parent.Event2.OnServerEvent:Connect(myEvent)
script.Parent.Event3.OnServerEvent:Connect(myEvent)