I've been making some Touched scripts and wanted to know if there's a difference between connecting the function whenever the part is touched, because I've seen people do it two different ways.
The way I normally do it is:
1 | function Test() |
2 | print ( "Hello!" ) |
3 | end |
4 |
5 | script.Parent.Touched:Connect(Test) |
But I've seen some other people use:
1 | script.Parent.Touched:Connect( function (Test) |
2 | print ( "Hello!" ) |
3 | end ) |
Is one way better to use then the other, or is it just used differently for cosmetic purposes?
It depends, if you are looking to create your own function and be a little more advanced, then use your way. If not, then you may use Roblox functions (in this case: "Touched").
The only difference is that your way is your own function and the second way is a function built into lua. They both do the exact same things in terms of functionality.