|
| 16 Jan 2012 08:44 AM |
enabled = true
function onClicked() if not enabled then return end enabled = false local p = Instance.new("Part") p.Position = script.Parent.Parent.Drop.Position p.Size = Vector3.new(2,1,4) p.Name = "CabbageBrick" p.Parent = script.Parent.Parent.Parent
script.Parent.ClickDetector:remove() script.Parent.Transparency = 1 wait(5) local c = Instance.new("ClickDetector") c.MaxActivationDistance = 32 c.Parent = script.Parent script.Parent.Transparency = 0 enabled = true end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
-------------------------------------------------------------------------------
Ok so this is inside a brick in which when clicked tells another brick to create the "Part". That works fine. But not the second time. It worked before i added things about adding/removing "ClickDetector". The "ClickDetector" gets created correctly but it still does not connect. Any solutions/other ways of doing this? |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2012 08:45 AM |
| Wow...that was probably the biggest fail i've made in scripting...all i have to do is enable/disable the clickdetector 0_0 |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2012 08:50 AM |
| ...nvm...i still need help please |
|
|
| Report Abuse |
|
|
352ynnhoj
|
  |
| Joined: 21 Sep 2010 |
| Total Posts: 1054 |
|
| |
|
352ynnhoj
|
  |
| Joined: 21 Sep 2010 |
| Total Posts: 1054 |
|
|
| 16 Jan 2012 08:55 AM |
| Also you didnt define what enable was. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2012 04:31 PM |
| enabled is a variable within the script....it doesnt change anything outside the script (like ting = 1 and stuff like that) |
|
|
| Report Abuse |
|
|
rcm
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 621 |
|
|
| 24 Jan 2012 05:24 PM |
You shouldn't be remove()ing the click detector, since that disconnects the onClick() function. It looks like your just trying to make a 5 second debounce so try this: (It sets the maxactivationdistance to 0 for 5 seconds, then back to 32)
enabled = true
function onClicked() if not enabled then return end enabled = false script.Parent.ClickDetector.MaxActivationDistance = 0 local p = Instance.new("Part") p.Position = script.Parent.Parent.Drop.Position p.Size = Vector3.new(2,1,4) p.Name = "CabbageBrick" p.Parent = script.Parent.Parent.Parent
script.Parent.Transparency = 1 wait(5) script.Parent.ClickDetector.MaxActivationDistance = 32 script.Parent.Transparency = 0 enabled = true end
script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 27 Jan 2012 03:41 PM |
| oh yeah...i didnt think about that...thanks! |
|
|
| Report Abuse |
|
|