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

How do you make a double click script for a TextButton?

I'm trying to make a gui where if I double click within a span of 1s, it would do something else. I tried using this script, but it doesn't really work that well.

button.MouseButton1Click:Connect(function()
	local wantTo = true
	button.MouseButton1Click:Connect(function()
		if wantTo == true then
			--Double click script
		end
	end)
	wait(1)
	wantTo = false
	--Single click script
end)

1 answer

✓ Accepted answer

###What your current script is doing:

#On line 1, it listens for the MouseButton1Click event

#On line 3, it’s overwriting the listener for line 1, thus line 1’s code not running

###To fix this, add a counter and add +1 to it.

local counter = 0

button.MouseButton1Click:Connect(function()
    counter = counter + 1
    
    if counter == 2 then
        -- Code
    end
end)

###Hope I helped.

1 comment

0

Ah, I see. Thanks for the help :)

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