|
| 21 Dec 2011 02:05 PM |
I use it because it makes the script work, but I don't understand why. Let me give an example:
function OnTouched ()
Now, you could have: function OnTouched(hit)
In the second example, the brackets serve a purpose. |
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 21 Dec 2011 02:10 PM |
| What? Are you too lazy to writena few parenthesises? |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 21 Dec 2011 02:13 PM |
The brackets clarify that you are calling/defining a function.
function a() print("Cookies") end
print(a()) print(a) >Cookies >function: [Hexadecimal code presumably of the function's memory address] |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:18 PM |
So would I not need to put () after an 'if' For example, which would work: if OnClicked()
or
if OnClicked |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:25 PM |
Well, what you just said in the 'if OnClicked()' (Which btw has some errors), you are assuming that the function returns true or false.
i.e.
function OnClicked() return true end
And the second if statement (which also has errors), you are just checking if the variable 'OnClicked' is defined, A.K.A if it's not nil. |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:48 PM |
You sometimes shouldn't put it there.
local x = math.random() print(x) > some decimal
local x = math.random print(x) > some hexadecimal memory address |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:49 PM |
| Basically, the parentheses is telling it to call the function, whereas when you don't it's getting the memory address of it. |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:54 PM |
| Sometimes they are used in editable scripts to show the editors you need to put something in I think :) |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:56 PM |
@ellie not even close. They tell the script that an actual function is being called. |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 21 Dec 2011 02:57 PM |
Parenthesis show the absence of argument(s). That's all. When you call a function, you use them to shown the absence of arguments, not to call it.
function sayHello() print("Hello!") end sayHello()
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 21 Dec 2011 02:58 PM |
Ugh... my end was in a different place (but it would still work my first way).
function sayHello() print("Hello!") end
sayHello()
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 02:59 PM |
| Sorry I think im thinking of something else, do you know what I'm thinking of??? |
|
|
| Report Abuse |
|
|
Pyzothon
|
  |
| Joined: 26 Oct 2011 |
| Total Posts: 822 |
|
|
| 21 Dec 2011 03:01 PM |
Uh...
If you're wondering why we need to use parenthesis in a function like this:
function onTouched()
It shows the absence of arguments, like I said before.
Pyzothon, novice scripter/programmer. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 21 Dec 2011 03:05 PM |
Because that's where the argument is supposed to go
function kill(...) for _,n in pairs({...}) do for __,p in pairs(game.Players:players()) do if p.Name:lower()==n:lower() then pcall(function() p.Character:BreakJoints() end) end end end end
kill("nate890","someone")
Or you can make a custom pseudo print
function printt(...) local str={} for _,s in pairs({...}) do table.insert(str,tostring(s)) end print(unpack(str)) end
printt("1","2")
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 03:08 PM |
They are there for noobs to go raid leik you.
http://www.roblox.com/Part-Generator-Plugin-V2-item?id=68062295 |
|
|
| Report Abuse |
|
|
|
| 21 Dec 2011 03:08 PM |
*Raig*
http://www.roblox.com/Part-Generator-Plugin-V2-item?id=68062295 |
|
|
| Report Abuse |
|
|