The word inside of the parentheses of the function is known as a parameter, which is essentially a placeholder for any value that is sent into the function.
For example, take a look at the following function:
local function testFunction(parameter)
print(parameter) -- This would print Hello!
end
testFunction("Hello!")
When the function is activated, a value was sent into the function (in this case, that was the string "Hello!"
). When the function receives that piece of data, it can then be referenced by the parameter inside of the function’s parenthesis. This can be done with multiple DataTypes without needing to change the parameter, as shown below:
local part = workspace.partNameHere
local function testFunction(parameter)
print(parameter)
end
testFunction("Hello!") -- The function would print Hello!
testFunction(part.BrickColor) -- The function would print the BrickColor property of the part
However, let’s say that we send an Instance through instead. In this case, we’d be able to reference objects from its “perspective”
local Folder = workspace.folderNameHere
local part = Folder.partNameHere
local function testFunction(partThatWasSentThrough)
print(partThatWasSentThrough.Name) -- This would print partNameHere
local parentOfPart = partThatWasSentThrough.Parent -- This will reference what contains the part
warn(parentOfPart.Name) -- This would print "folderNameHere"/the name of the object that contains it
end
testFunction(part) -- This will activate the function, sending the part (referenced on line 2) into it
(I added this second codeblock after re-reading and realizing I didn’t read the OP close enough, so this example should provide a better explanation for your use case. Let me know if you have any additional questions!)
More information about this can be found on the following pages:
Developer Hub Resources
Variables Article
Functions Article
NEW: Developer Onboarding
Education.Roblox Resources
Variables Tutorial
Parameters and Events Tutorial – This page has examples that include what you are trying to achieve, too!