edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 05:25 PM |
Script: p = script.Parent function onClick(click) p.Parent.Door.CanColide = false and p.Parent.Door.Transparency = 1 wait(3) p.Parent.Door.CanColide = true and p.Parent.Transparency = 0 end p.ClickDetector:MouseClicked:connect(onClicked)
Eror: Script:3: unexpected symbol near '='
What does it mean and how can i fix it?
|
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 19 Dec 2012 05:29 PM |
p = script.Parent
function onClick(click) p.Parent.Door.CanColide = false p.Parent.Door.Transparency = 1 wait(3) p.Parent.Door.CanColide = true p.Parent.Transparency = 0 end
p.ClickDetector:MouseClicked:connect(onClicked)
This should work. n_n |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:29 PM |
Script: partSelect = script.Parent
partSelect.ClickDetector.MouseClick:connect(function() partSelect.Parent.Door.CanColide = false partSelect.Parent.Door.Transparency = 1 wait(3) partSelect.Parent.Door.CanColide = true partSelect.Parent.Transparency = 0 end)
|
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 19 Dec 2012 05:30 PM |
Oh wait, I didn't notice you missed a 'Door' when changing back the Transparency.
p = script.Parent
function onClick(click) p.Parent.Door.CanColide = false p.Parent.Door.Transparency = 1 wait(3) p.Parent.Door.CanColide = true p.Parent.Door.Transparency = 0 end
p.ClickDetector:MouseClicked:connect(onClicked) |
|
|
| Report Abuse |
|
|
edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 05:32 PM |
| Ohhhhhh. I'll try it, thanks. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:32 PM |
I didn't see that either. I would also like to add anonymous functions are better than connection line ones. Also, declaring variables with useful names with definition will help in a larger script, so start doing it with smaller ones.
- thedestroyer115 |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:40 PM |
Is it just me or did nobody notice the fact that 'CanColide' is not a property? Just asking? Here is a fixed script. There were a few errors I saw. (Please tell me if I'm wrong, sorta new to Lua).
p = script.Parent
function onClick(click) p.Parent.Door.CanCollide = false --CanCollide is a property, not CanColide. p.Parent.Door.Transparency = 1 wait(3) p.Parent.Door.CanCollide = true p.Parent.Transparency = 0 end
p.ClickDetector.MouseClicked:connect(onClick) -- ** see below
** here on your function calling you put "p.ClickDetector:MouseClicked:connect".
This will error the script as it will try to find 'MouseClicked' as an event or function. Furthermore, you put 'OnClick' as your function in the ( ), but is not the name of the function that you put.
Hope this helps.
MouseClicked is a hidden property of P.ClickDetector'. |
|
|
| Report Abuse |
|
|
edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 05:41 PM |
When I test it, it says: attempt to call a nil value Disconnected event because of exception
|
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:41 PM |
| Also, change that "p.Parent.Transparency = 0" to "p.Parent.Door.Transparency = 0". That is not an error that will show up but your door will stay transparent forever. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:46 PM |
Finally fixed script:
partSelect = script.Parent
partSelect.ClickDetector.MouseClick:connect(function() partSelect.Parent.Door.CanCollide = false partSelect.Parent.Door.Transparency = 1; wait(3) partSelect.Parent.Door.CanCollide = true partSelect.Parent.Door.Transparency = 0 end)
- thedestroyer115 |
|
|
| Report Abuse |
|
|
edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 05:50 PM |
| No errors, but door won't open... |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 05:52 PM |
Can you give us an idea of what your explorer tree looks like?
This is what I am thinking it is.
Workspace -Model --Script --Door
Is that what it looks like? |
|
|
| Report Abuse |
|
|
edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 06:16 PM |
| workspace-model-door, part-Clickdetecor, script |
|
|
| Report Abuse |
|
|
edc900
|
  |
| Joined: 25 Apr 2010 |
| Total Posts: 170 |
|
|
| 19 Dec 2012 06:21 PM |
-workspace --modle door part-script+clickdetector |
|
|
| Report Abuse |
|
|