How to make tap and hold button

how do i make a function continuously run every .5 seconds while a TextButton is being held down

RobloxStudioBeta_xIgUMAZmNf

local Button = script.Parent
local IsDown = false
local Count = 0

Button.MouseButton1Down:Connect(function()
	IsDown = true 
	
	repeat 
		Count += 1 
		Button.Text = tostring(Count)
		
		task.wait(0.5)
	until (IsDown == false)
end)

Button.MouseButton1Up:Connect(function()
	IsDown = false
	
	Count = 0
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.