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

I am trying to make an anti-autoclick but i'm confused on how to use tick()?

Asked by
PolyyDev 214 Moderation Voter
7 years ago

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:

01bitbtn.MouseButton1Click: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
10end)

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

0
use debouce abnotaddable 920 — 7y

2 answers

Log in to vote
2
Answered by 7 years ago

You would check how quick they click. I would say humans can't click every millisecond. So, we could do this.

1local last = 0
2script.Parent.MouseButton1Click: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()
9end)

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!

Ad
Log in to vote
0
Answered by 7 years ago

i never really used tick() but i would do this.

01clicked = false
02bitbtn.MouseButton1Click: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
10end
11 
12 
13end)

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

Answer this question