What is the difference between end) and end? I have seen both types of ends but I never really understood it. Usually, I just add t because it works for the script.
There is one type of end
, which is without the parenthesis.
function func() end
This is the only type of end
in existence.
The only reason there might be a parenthesis near the end
is because it needs to close another parenthesis. Every (
needs a )
.
You'll usually see this in anonymous functions combined with events.
script.Parent.Touched:connect(function() end)
This is how it's normally written, and this is how you should write it, but it can be a bit misleading. The parenthesis near the end
isn't a different 'type' of end
-- it's needed to close the left parenthesis of connect
.
Look at the code rearranged, it should make more sense:
script.Parent.Touched:connect( function() end ) --Closes parenthesis on line 1