generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Click Detector

Previous Thread :: Next Thread 
ShadowAlphaLord is not online. ShadowAlphaLord
Joined: 20 Jun 2013
Total Posts: 124
25 Jun 2015 08:21 PM
I want the script so when its clicked you cant click it for 10 seconds and then you can click it again. after i click it once it will destroy the clicker than make a new one.
but after its destroyed and there is a new one created it wont get destroyed again once clicked


function onClicked(onClicked)
script.Parent.ClickDetector:Destroy()
wait(10)
Instance.new("ClickDetector", script.Parent)
script.Parent.ClickDetector.Name = "ClickDetector"
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
25 Jun 2015 08:22 PM
local debounce = false

if not debounce then
debounce = true
--code
wait(10)
debounce = false
end
Report Abuse
ShadowAlphaLord is not online. ShadowAlphaLord
Joined: 20 Jun 2013
Total Posts: 124
25 Jun 2015 08:23 PM
sorry this is one without the pointless part

function onClicked(onClicked)
script.Parent.ClickDetector:Destroy()
wait(10)
Instance.new("ClickDetector", script.Parent)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
ShadowAlphaLord is not online. ShadowAlphaLord
Joined: 20 Jun 2013
Total Posts: 124
25 Jun 2015 08:24 PM
thank you
Report Abuse
ShadowAlphaLord is not online. ShadowAlphaLord
Joined: 20 Jun 2013
Total Posts: 124
25 Jun 2015 08:40 PM
it still only works once
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 08:41 PM
That's because you're removing the click detector when it's clicked.
Report Abuse
ShadowAlphaLord is not online. ShadowAlphaLord
Joined: 20 Jun 2013
Total Posts: 124
25 Jun 2015 08:43 PM
is there a way for it to work if i'm removing the ClickDetector
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 08:47 PM
cd = script.Parent.ClickDetector
function onClicked(onClicked)
script.Parent.ClickDetector:Destroy()
wait(10)
cd = Instance.new("ClickDetector", script.Parent)
end
cd.MouseClick:connect(onClicked)
Report Abuse
Wreckerbuster67 is not online. Wreckerbuster67
Joined: 29 Jul 2012
Total Posts: 1144
25 Jun 2015 08:49 PM
It breaks cause you'd need another event line for the new ClickDetector; but as everyone else is suggesting, just use debounce...

local debounce = coroutine.create(function() wait(10) end)

script.Parent.ClickDetector.MouseClick:connect(function()
if coroutine.running() == debounce then return end
coroutine.resume(debounce)
--code
end)

That's for if your script has wait() as well or something, but otherwise, do this:

local debounce = false

script.Parent.ClickDetector.MouseClick:connect(function()
if debounce then return end
debounce = true
--code
wait(10)
debounce = false
end)
Report Abuse
loomis0523BC is not online. loomis0523BC
Joined: 08 Jan 2015
Total Posts: 764
26 Jun 2015 03:51 AM
function onClicked()
script.Parent.ClickDetector.MaxActavtionDistance = 0
wait(10)
script.Parent.ClickDetector.MaxActavtionDistance = 32
end
script.Parent.ClickDetector.MouseClick:connect(OnClicked)


these may work i did not test it
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image