What exactly is a parameter?
In the Roblox Developer thing, it talks about parameters but I’m still not sure what it is.
Pls no bully I’m new to scripting
What exactly is a parameter?
In the Roblox Developer thing, it talks about parameters but I’m still not sure what it is.
Pls no bully I’m new to scripting
I don’t know how to exactly describe a parameter, but its stuff that is inside the ()
here is an example
local function aFunction(aParameter)
print(aParameter)
end)
aFunction("this is a parameter")
What does the parameter act as though. Like so function like is an action sorta. So what does the parameter do to the script?
Here, this is what it is:
local function myCoolFunction(first, second, third) -- We can take in as many parems as we like!
-- Now where did we get these vars from? We got them from the parems above
print(first..second..third)
end
myCoolFunction("Hello ", "DevForum", "!") -- When we call the function, we are filling up those parems, basically kinda like a form sheet.
-- Now, those parems act as provided variables in that function!
This is not exactly what a parem is, but it should get you on the right track.
It will print “this is a parameter” just like i wrote it inside the ()
So the thing in the () is a parameter?
Yes. It is inside the parentheses (or () if you don’t get what i mean)
Is a parameter sort of like a place holder?
It doesn’t matter how many parameters you put. Here’s s example:
local function printingFoodStuff(first, second, third, fourth)
print(first .. second .. third .. fourth)
end
printingFoodStuff("I love eating ", "burger, ", "sandwich and ", "more stuff! Lol") -- I love eating burder, sandwich and more stuff! Lol
Yes, but you can put any data type inside of it (numbers,parts or Instances,strings,variables and ect)
Not really… I have an example in my response.
@zaydoudou is technically right, but a more in-depth explanation is it’s like a variable thats’ passed on when you call the function, (the variable is passed on through the ())
Yes it is kind of like a placeholder (Not really)
What else is parameter used for? Is it just for printing?
No! You can use it as anything! It’s just like a variable being transferred to the function. So you can do strings, booleans, tables, numbers, instances, etc!
Me and @AridFights1 were using printing to explain the concept a bit better by putting those parems in use.
On second thought- Im gonna learn parameters later. I’m going to learn strings and stuff first so it’ll be easier to understand.
See parameters as arguments to a function, for example;
If I were to make a print script like the following…
function Output(Text)
print(Text);
end;
…Then, Text would be the argument/parameter to my print function. You can use parameters/arguments like this.
Output("This is an argument/parameter.");
Is the “This is an argument…” a parameter?
Yes, everything in between the () in the output function is a parameter.
(In this case, the string in between the () is the parameter.)
So basically, the stuff in a () is always a parameter?
I guess you could say that, yes.