for an exampe
local function hi([somthing here])
print("What does the bracket means D: I can't find my answer on the internet.")
end
for an exampe
local function hi([somthing here])
print("What does the bracket means D: I can't find my answer on the internet.")
end
The bracket for function() allows arguments to added in it. Example:
function(arg1)
print(arg1)
end
arg1("Hello World!")
The function would print Hello World! This use can allow developers to quickly run codes without copy and pasting it. Also this is very important for modules scripts too.
======After editing===========
A more complex situation for this would be a script requiring a module script to summon a part Exmaple:
Module Script:
local module = {}
function module:SpawnPart(position, partcolor)
local part = Instance.new("Part")
part.Position = position
part.Color3 = partcolor
print("Added part!")
end
return module
Script:
local module = require(moduleScript)
module:SpawnPart(Vector3.new(0, 0, 0), Color3.fromRGB(0, 50, 100))
Thanks, but can you give me an example on how you use it in one more complex script. :)
Ok let me get one
I would suggest searching up what arguments and parameters are because they play a major role in scripting. But I'll try to do my best to explain it.
--// Parameters are values inside of the brackets when you create the function
local function printingfunction(x)
print(x)
end
--// Arguments are the syntax used when you call your function
printingfunction("Hello World!")
--> Console would print Hello World!
This is a simple example of arguments and parameters. You can create more complex functions with multiple parameters and arguments
Sources: http://wiki.roblox.com/index.php?title=Arguments_and_parameters
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Brackets after the "function" - function()