How would I add a timer to my punch combo using tick()

I’ve tried making this using UserInputService, but I still can’t get it to work right. So far I’ve found nothing that helps me. This is what I have so far, it counts from 1 - 3 then it restarts, I want to make it so you have to click before 0.5 seconds for it to punch.

2 Likes

Using if everytime isn’t not nice idea.

local PreviousPunch = 0

mouse.Button1Down:Connect(function()
     if tick() - PreviousPunch <= 0.5 then -- If previous punch was operated in 0.5 seconds,
          if streak >= 3 then -- If streak was continued for 3 times,
               streak = 0 -- change streak to 0.
          end
          streak = streak + 1 -- make streak +1.
     else -- If time from last punching operation was over than 0.5 seconds,
          streak = 0 -- reset your streak.
     end
     PreviousPunch = tick() -- you punched, so this will be previous punch time.
end)

Comment describes it. Let me know if this one was wrong.

6 Likes

Thanks ,this solves my problem.

1 Like