Basically when you fire the function, it those variables will be the same thing as the ones passed as the arguments.
local function testFunction(argument1,argument2,argument3)
print(argument1,argument2,argument3)
end
Those three arguments will change their value based on what is passed on when you fire the function:
testFunction("foo","bar","obama")
if we pass those values, argument1 will be "foo", argument2 will be "bar" and argument3 will be "obama".
testFunction("aNormalString","anotherString","aVeryRandomString")
that will make argument1 be "aNormalString", argument2 be "anotherString" and argument3 be "aVeryRandomString".
But we can send a lot of things, not only strings. This is an example where we can modify a part:
local function modifyPart(part,name,color,canCollide)
part.Name = name
part.Color3 = color
part.CanCollide = canCollide
end
modifyPart(game.Workspace.someRandomPart,"aNewName",Color3.fromRGB(255,255,255),false)
As you can see, we are firing a Instance (the part), a String (the name), a Color3 (color) and a Boolean, (the CanCollide property).
Quick note:
- The variables inside the function can be named whatever you want, they will still remain the value they are fired with.
1 comment
Look up Arguments & Parameters in Lua to get a better understanding.