Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to detect the player is clicking & holding ?

Asked by 5 years ago

So i have a gui button and i want to create a easter egg function by clicking and holding it for 2 second This is a script i currently have in my mind

1script.Parent.MouseButton1Down:Connect(function()
2if script.Parent.MouseButton1Up then
3else
4wait(3)
5--Secret function
6end
7end)

Idk if that works. Is there a better way of doing this ? Thanks for reading, hope you could help :D

1 answer

Log in to vote
1
Answered by 5 years ago
01script.Parent.MouseButton1Down:Connect(function()
02    local isholding = true
03    script.Parent.MouseButton1Up:Connect(function()
04        isholding = false
05    end)
06    wait()
07    if isholding then
08        --Secret Function
09    end
10end)
0
Oh i will try it out, thanks ! (I will accept if it works) Nguyenlegiahung 1091 — 5y
Ad

Answer this question