How to check how many times a clickdetector has been clicked

im trying to make a telephone when you press a button 3 times a part falls from the sky trying to keep it simple but i got this problem.

2 Likes

What does your clickdetector script look like so far?

If you don’t know where to start, there is a very simple example here:

You could take something like that and do something like this:

local clickcounter = 0
local clickDetector = workspace.Part.ClickDetector
 
function onMouseClick()
	clickcounter = clickcounter +1
	print("You clicked me ".. clickcounter .. " times!")
end
 
clickDetector.MouseClick:connect(onMouseClick)
3 Likes

This topic should be in #help-and-feedback:scripting-support.


This simple problem has a simple solution. It’s using a variable to count how many times has been clicked:

local Count = 0
local function Clicked()
   Count += 1
   if Count == 3 then
      Count = 0 --Resets the count
      -- Do stuff
   end
end

ClickDetector.MouseClick:Connect(Clicked)
3 Likes