|
| 22 Jan 2013 08:50 PM |
Hello. My touched script isn't working. Output: Attempt to call a nil value
Script:
function touched(object) print("Touched") end script.Parent.Touched:connect(touched())
I just put an un-anchored part above the part this script is attached to, the first few times it worked, now it doesn't. Why? |
|
|
| Report Abuse |
|
|
|
| 22 Jan 2013 08:52 PM |
In connect(), you don't put the brackets of the function in it. i.e. script.Parent.Touched:connect(touched) |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 22 Jan 2013 09:09 PM |
@eye anonymous functions are;
script.Parent.Touched:connect(function(touched) |
|
|
| Report Abuse |
|
|
|
| 22 Jan 2013 09:12 PM |
@Azarth
Then, he would need a closed parenthesis in the end...
@op
The basic idea of anonymous functions is this:
[Object].[Event]:connect(function (argument)
--Code
end)
There is no need to name the function because it already is self defined.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Jan 2013 09:32 PM |
Op = Original Poster -- Person who created this thread.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
|
| 22 Jan 2013 09:42 PM |
@Eye yours worked
@Azrath I didn't want it to be anonymous... |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jan 2013 04:44 PM |
| I have this wierd feeling, like I helped somebody..oh wait, I did. :DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 23 Jan 2013 05:28 PM |
@Jonah
That wasn't the best explanation of an anonymous function(even if it was a basic explanation)
(function(arg) print(arg) end)("hi") |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2013 01:54 PM |
| I know how anonymous functions work guys. |
|
|
| Report Abuse |
|
|