Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont this click detector script work?

bell = script.Parent function clickit() bell.ClickDetector:Destroy() wait(20) Instance.new("ClickDetector", bell) end bell.ClickDetector.MouseClick:connect(clickit)

This should make it so after you click the bell it removes the click detector for 20 seconds and puts a new one. It works the first time but after that I doesn't remove it.

1 comment

0

2 years later you accept my answer. GG

1 answer

✓ Accepted answer

Instead of removing the ClickDetector, you can access the MaxActivationDistance property. So:

bell = script.Parent
activated = false

function clickit()
	if activiated == false then
		activated = true -- I recommend setting a debounce in-case a player or more clicks it multiple times.
		bell.ClickDetector.MaxActiviationDistance = 0
		wait(20)
		bell.ClickDetector.MaxActiviationDistance = 32 -- The default distance I believe
		activated = false
	end
end

bell.ClickDetector.MouseClick:connect(clickit)

This discussion is preserved as it was. New answers, comments, and votes are closed.