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

What goes in the parentheses of a function?

Asked by 6 years ago

What goes in between the parentheses?

function example()

end

2 answers

Log in to vote
0
Answered by 6 years ago

In the parentheses of such a function, what could be in there is what is known as a parameter. Parameters are variables created by the function that can stand for basically anything. Example:

function Weld(p1, p2) -- Two parameters; you can have more than one
    local w = Instance.new("Weld", game.JointsService)
    w.C1 = p2.CFrame:toObjectSpace(p1.CFrame)
    w.part0 = p2
    w.part1 = p1
end
Weld(game.Workspace.Part, game.Workspace.Wedge)
--[[
Please note that all parameters must be filled in for the function to work.
If no parameters are defined, you'll get an error or the script will be a dud.
--]]
0
thanks. Revisedy 23 — 6y
Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago

Example:

function Print(text) -- you can put anything between the parentheses. Strings, objects, properties 
    print(text)
end

Print('Hello world!') -- prints 'Hello world!' in the output

Answer this question