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

What do the double parenthesis without anything inside do and why do people use them?

Asked by 4 years ago

This may seem like a dumb question but, what do the double parenthesis without anything inside exactly do? I've seen them quite often, though I'm still not too sure of what their purpose is. The internet doesn't exactly give specific answers. e.g.

local function addNumbers()
0
Parameters are supposed to go inside double parenthesis. Geobloxia 251 — 4y

2 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

when your defining a function, you'll often specify arguments that will be passed when the function is called. the parameters are set in the parenthesis..

for instance:

function addNumbers(numberA, numberB)
    return numberA + numberB
end

local result = addNumbers(1,2)
print(result)

or

function sayHello()
    print("Hello there")
end
sayHello()

or

function greet(personsName)
    print("Hello, "..personsName)
end
greet("JustPhysical")

learn more here

Ad
Log in to vote
1
Answered by 4 years ago

Parameters are left blank usually for simple functions. However, you will see parameters in the double brackets in more complex functions. Events(or most, I'm not sure) will give a parameter depending on the event (ex. a touched event provides the part that touched the block)

In conclusion, empty brackets are not commonly found in functions, but they do exist.

Answer this question