Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the difference between end) and end?

Asked by
Yeevivor4 155
8 years ago

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.

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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
Ad

Answer this question