Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i know what the function is in the parenthesis in the function..? read more..

Asked by 6 years ago

So I am a normal scripter and I was wondering suppose I make a function, normally when I get scripts I find stuff in the parenthesis, but, how would u know what that means: For example....

function somethingrandom(something)

How would I know what the something is? Would I need to define it?

0
when you call your function, you define it. So somerandomthing(the thing "something" should be) lukeb50 631 — 6y
0
so for example `function somethingrandom(something) something = 1 print(something) end will that work? greatneil80 2647 — 6y
0
It would technically work, but probably not the way in which you think it would. Unless you're passing an object or a table (a reference, generally speaking), arguments are passed as a copy. In other words, you're not modifying the variable you passed to the function, but only a copy of it. XAXA 1569 — 6y
0
It is like all the other global functions, like "print()". It gives you a parameter to fill in, which ROBLOX puts it in the output based on the parameter. hiimgoodpack 2009 — 6y
0
oh okay thanks greatneil80 2647 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

This is pretty simple, let's say you have this

function printThis(msg, anothermsg)
print(msg) -- since 'msg' is technically a variable we can just print it out
print(anothermsg) -- same with this one, it's a variable so we can print it out, however if the second argument wasn't specified when we called the function it would just print nil, since it's not defined.
end

printThis("hello world!", "hello world 2!") -- as you can see here in the arguments of the function we insert a string which will in the function be referred to as a variable. As you can see we have two arguments in this function, you can have how many you want.

This might not be the best answer, but should give you an estimate on how it works.

0
This explains it all, thanks greatneil80 2647 — 6y
Ad

Answer this question