I know this :
function example() end
But then do I use local or Arguments / parameters?
Functions are used to make your code a lot more organized and convenient. For example let's say you wanted to create two parts a bunch of times in your code, then a function that creates two parts when you call it is really helpful.
Parameters are used when you have a function that requires more information to run. For example, if you have a function that creates a certain amount of parts based on what you input, then you use parameters.
Example:
function CreateParts(numberOfParts) -- parameter is the number of parts to create for i=1,numberOfParts do -- for loop to create the number of blocks local part = Instance.new("Part", workspace) -- part instance in workspace end end CreateParts(7) -- This creates 7 parts CreateParts(100) -- This creates 100 parts
From what I understand, you want a function that creates two parts. So you do not need parameters in your function. You only need to make two parts.
This would create the following:
function example() -- function to create two blocks local p1 = Instance.new("Part", workspace) -- creates one block local p2 = Instance.new("Part", workspace) -- creates another block end example() -- Creates two blocks example() -- Also creates two blocks
I hope I explained the purpose of parameters well enough and was able to help out.
What I’m thing is Arugments and parameters. So I think the script would look like this :
function part(name,trans,anchor,collide) local part1 = Instance.new(“part”) part1.name = name part1.transperency = trans part1.Anchored = anchor part1.CanCollide = collide end part(hello,0,true,true)
I don’t know if that’s right or not. Please remind me if it is