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

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

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?

5 comments

0

when you call your function, you define it. So somerandomthing(the thing "something" should be)

0

so for example `function somethingrandom(something) something = 1 print(something) end will that work?

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.

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.

0

oh okay thanks

1 answer

✓ Accepted answer

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.

1 comment

0

This explains it all, thanks

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