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

Why doesn't this script work? It plays both animations instead of just one each time.

Asked by 7 years ago

So when a player clicks once, it plays [1] If a player clicks twice, before 0.3 seconds are over, it plays [2] If a player clicks three times, before 0.5 seconds, it plays [3] If they don't click before the certain time limit, it plays 1. The issue I keep getting is if a player clicks twice, it plays both 2 AND 3. How do I fix this?

01function button1Down()
02    if (activated and not animating) then
03        if (secondSlash and tick()-secondSlashTime < 0.3) then
04            slash[2]()
05            secondSlash = false
06 
07        if (activated and not animating) then
08            if (thirdSlash and tick()-thirdSlashTime <0.5) then
09                slash[3]()
10                thirdSlash = false
11            end
12        end
13        else
14 
15            slash[1]()
16            secondSlash, secondSlashTime = true, tick()
17            thirdSlash, thirdSlashTime  = true, tick()
18        end
19    end
20end

Answer this question