function onClicked()
script.Parent.Parent.Screen.SurfaceGui.Enabled = false
script.Parent.Parent.Click.ClickDetector:Destroy()
wait(3)
script.Parent.Parent.Screen.SurfaceGui.Enabled = true
wait(3)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
So, I want it to do loop like detector disable then enable back when going on main Screen of GUI. I did put detector to destroy, I tried with archivable to be false as disabled.
I’d suggest making a variable that is a boolean. ex :
local isClicked = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if isClicked then return end
isClicked = true
-- code
wait(time)
isClicked = false
end)
Um that script won’t do anything since return just end the function correct me if i’m wrong. And adding the bool value won’t help cause it is just a debounce.
About the problem, are there 2 click detectors cause this:
Destroying click detectors and adding them is not the best solution.
1st you would need to do that on server
2nd everytime an object is created, packets are being sent