Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is the value of parametes the value of the parameters when the function is called?

If I was to create this script

Button = script.Parent

function Add(One, Two)
	print(One + Two)
end

Button.MouseButton1Click:connect(function(Add)
end)
-- So, in parameters, I am assuming the value of the parameters, in functions, is the value of the --function of the parameter called correct?
--Example
--I call the function Add
--Add(1, 2)
--So the value of strings "One" and "Two" are the value of the parameter when the function is --called which is 1 and 2 right?
-- So it prints 3



-- Is this true?

3 comments

0

Please format your code with the Lua button.

0

Edited to fix code formatting

1

Basically, a parameter is a variable without value, the only time it can be 'valued' is if it is assigned when the function is called.

1 answer

Not exactly sure what you're asking, but I'll try my best to give some information on parameters.

So, let's say that we have a function that will create a part, and it takes in a few parameters: Size, Position, Color, and finally PartType. Let's go ahead and setup such a function.

local createPart = function(s, p, c, pT) -- You could also just do local function createPart(s, p, c, pT), same thing.
 if pT:lower() == "part" then
  local i = Instance.new("Part", workspace)
  i.Size = s
  i.Position = p
  i.BrickColor = c
  return i
 elseif pT:lower() == "wedge" then
  local i = Instance.new("WedgePart", workspace)
  i.Size = s
  i.Position = p
  i.BrickColor = c
  return i
 end
end

local myPart = createPart(Vector3.new(4, 4, 4), Vector3.new(0, 50, 0), BrickColor.palette(math.random(0,127)), "Part")

So, the above function sets up a function that, again, takes in some parameters for making a part. We can call this function and supply it the parameters that we want, and voila.

There's a lot you can do with parameters, so with the information you've been given, experiment around and you'll get the hang of it in no time.

Hope this helps, MINEBLOX106.

This discussion is preserved as it was. New answers, comments, and votes are closed.