I have a game and when you click a button it gives you money but I don't want people to anuse it with autoclicker. I have tried many different things but this is the main one:
01 | bitbtn.MouseButton 1 Click:Connect( function () |
02 | local anticlick = tick() |
03 | if tick() - anticlick < 0.3 then |
04 | print ( "Clicked: " ..tick() - anticlick) |
05 | elseif tick() - anticlick > 0.3 then |
06 | print (tick() - anticlick) |
07 | playerData.Bitcoins.Value = playerData.Bitcoins.Value + 5 |
08 | updateData() |
09 | end |
10 | end ) |
It just comes up with something along the lines of: Clicked: 1.6689300537109e-06
no matter how fast it is clicked ( I tested an auto clicker ) and i'm out of ideas so if someone could help me fix this or has a different method please answer or comment.
~Ki_ngPhantom
You would check how quick they click. I would say humans can't click every millisecond. So, we could do this.
1 | local last = 0 |
2 | script.Parent.MouseButton 1 Click:Connect( function () |
3 | if tick() - last < = 0.001 then --if the last click was less or equal to 1 millisecond |
4 | print ( 'Turn off your autoclicker!' ) |
5 | else |
6 | print ( 'You clicked it! Yay!' ) |
7 | end |
8 | last = tick() |
9 | end ) |
So, what does this do? last
is the seconds since the last click. tick
provides the number of seconds and milliseconds from a date, not really important what that date is.
You also probably learned to use subtraction to see how many more a value is than another, so that is what I did.
Hope this helps!
i never really used tick() but i would do this.
01 | clicked = false |
02 | bitbtn.MouseButton 1 Click:Connect( function () |
03 | if clicked = = false then |
04 | clicked = true |
05 |
06 | playerData.Bitcoins.Value = playerData.Bitcoins.Value + 5 |
07 | updateData() |
08 | wait( 1 ) |
09 | clicked = false |
10 | end |
11 |
12 |
13 | end ) |
this i basicly made it where on clicked then i would change the bool value to true and it cant be activated again until the bool value is false again. if that kind of makes since