I want to figure out how to press and hold a button (On a SurfaceGUI).
If the button has been held down for at least 2 seconds I want it to bring a submenu (I have something for this already, and it’s submenu UI and animation)
This is an example of IOS’ menu.
I do not know how I can make the script see that I’m pressing and holding the textbutton for at least 2 seconds.
This is the button on the SurfaceGUI
If you require further explainations, I will try that. My explainations are not the best.
local timeBetween = 0
local down = false
script.Parent.MouseButton1Down:Connect(function()
down = true
task.spawn(function()
repeat wait(0.1)
timeBetween += 1
until timeBetween == 2 or down == false
if timeBetween ~= 2 then return end
print("Mouse was held down on button for 2s")
end)
end)
script.Parent.MouseButton1Up:Connect(function()
timeBetween = 0
down = false
end)
BTW, this was written on mobile so it is untested (but should check to see when the button was held for 2 seconds) and could contain errors