How would I script for a click detector to destroy after it's clicked once and then after you wait two mins, the clickdetector comes back?
I think the code would have:
Script.Parent:Destroy()
and maybe wait(120)
and then script.Parent:Clone()
but i am a bit confused.
Also, I think you would have to put the script in the Clickdetector.
Thank You and help is appreciated
local click = script.Parent.ClickDetector --or wherever it is click.MouseClick:Connect(function(player) click.Parent = nil wait(20) click.Parent = script.Parent end)
Hi aspiringstar346,
local detector = script.Parent; -- The Click Detector, which is the script's parent. local deb = false; -- The debounce for the click detector. This is the boolean value we're going to change to activate cool down. detector.MouseClick:Connect(function(plr) -- Anonymous function for the Mouse Click on the Click Detector. if not deb then -- Checks if deb is false, and if it is, then it can go ahead and run the function. deb = true; -- Makes it true so that this function can't be run until deb is false. print("It was clicked."); -- Prints "It was clicked" for testing purposes. wait(120); -- Waits for 120 seconds since that's the cool down. deb = false; -- Makes deb false so that the function can run again. end -- end for if statement end) -- end for anonymous function.
Thanks,
Best regards,
~~ KingLoneCat
1 local click = script.Parent.ClickDetector 2 3 click.MouseClick:Connect(function(player) 4 click.Parent = game.Players 5 wait(20) 6 game.Players:FindFirstChild("click").Parent = thing you got the click detector in 7 end)