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

Differences between "end" and "end)"? [closed]

Asked by 4 years ago

Hello, Im pretty new to scripting, so Im just confused about the differences between "end" and "end)".

Locked by JesseSong

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
5
Answered by 4 years ago

In Lua, there is no end). end and ) are two different things. ) is used to close something when it is opened with (. For example:

local func = function() print("hello") end
string.dump(func)

This is the same as:

string.dump(function() print("hello") end)

Only difference is that the function has a ( before it starts. So you have to end the function with ). Hopefully this helped!

2
This is correct ^^. The braces are argumental parentheses, and are expecting a function callback. The end just happens to meet the closing bracket. Ziffixture 6913 — 4y
0
Alright, thanks so much! mcslimeman 37 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

end is used to wrap up if statements, loops, etc.

What end) does is ends :Connect()

script.Parent.Touched:Connect(function() there is one parenthesis missing here, so you must include it when you say end. This will make it end)

end wraps something up when there is not a parenthesis missing, while end) is used when you need an extra parenthesis, like in the :Connect() example.

0
It's not privy to Connect. Connect expects a function callback as an argument—standard syntax is (). If you create a function, the end will meet the closing bracket. Ziffixture 6913 — 4y