creed0117
|
  |
| Joined: 29 Sep 2009 |
| Total Posts: 135 |
|
|
| 21 Dec 2011 12:25 PM |
Its for a door, and when i click it it opens, and when i click again, it closes.
function onClicked() script.Parent.Transparency = 1 script.Parent.CanCollide = false
function script.Parent.Transparency = 0 script.Parent.CanCollide = true
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
OP doesnt say anything.
Thanks, Creed0117
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Dec 2011 12:49 PM |
function onClicked() script.Parent.Transparency = 1 script.Parent.CanCollide = false
function -- function what? Do you want a wait here or something? script.Parent.Transparency = 0 script.Parent.CanCollide = true
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
creed0117
|
  |
| Joined: 29 Sep 2009 |
| Total Posts: 135 |
|
|
| 21 Dec 2011 01:00 PM |
Would that work if i wanted to "Click" again to close the door?
function onClicked() script.Parent.Transparency = 1 script.Parent.CanCollide = false wait(3) script.Parent.Transparency = 0 script.Parent.CanCollide = true
end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Dec 2011 01:03 PM |
| No, because you have two ends. But if you remove one of the ends then yeah, it would work. |
|
|
| Report Abuse |
|
|
creed0117
|
  |
| Joined: 29 Sep 2009 |
| Total Posts: 135 |
|
|
| 21 Dec 2011 01:05 PM |
So:
function onClicked() script.Parent.Transparency = 1 script.Parent.CanCollide = false wait(3) script.Parent.Transparency = 0 script.Parent.CanCollide = true
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
So this would make the door open on one click and click again to close it?
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Dec 2011 01:07 PM |
1st Yes, that would work
2nd What it would do is when you click it would open the door. Then three seconds later it closes. |
|
|
| Report Abuse |
|
|
creed0117
|
  |
| Joined: 29 Sep 2009 |
| Total Posts: 135 |
|
|
| 21 Dec 2011 01:08 PM |
Great, thank you miz for your help :]
~~Creed0117 |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 21 Dec 2011 01:10 PM |
Here is a way to get the thing to work when you click: d=script.Parent script.Parent.Clicked:connect(function() if m==false then d.CanCollide=false d.Transparency= 0.3 m=true elseif m==true then d.CanCollide=true d.Transparency= 0.3 m=false end)
|
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Dec 2011 01:13 PM |
Digpoe
That wouldn't work
1st The anonymous function isn't right
2nd You never defined what m is
|
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 21 Dec 2011 01:15 PM |
| m is a boolean, it's assigned the value "true" - and the whole script works fine in my place, so why do you say it dosen't? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 21 Dec 2011 01:18 PM |
script.Parent.Clicked:connect(function()
Unless the scripts parent is the clickdetector that wouldn't work. And even if it is. You would be clicking nothing -_- Which wouldn't make sense.
if m == false then
You never defined m. In the beginning of a script, you would have to say
m = false --code if m == false then
|
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 30 Dec 2011 04:56 AM |
| That is weird then 0.o - the script works fine on my place - and the script's parent is ment to be the PART, since you dont need a clickdetector in most cases, and I just don't know anymore.. I am going to be quiet, like usual..... |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 30 Dec 2011 11:40 AM |
| Ok...If it works it works :l |
|
|
| Report Abuse |
|
|