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

Method for making a combo system?

Asked by
Acryius 22
7 years ago

Was wondering what was the best method for making a combo system?

Example: Everytime you press the left mouse button, the console will print(x), x in this case is the number of times you pressed the left mouse button, however if you don't press it in a certain amount of time x resets back to 1.

Sorry if it's hard to understand, was just looking for a good method.

Thank you.

1 answer

Log in to vote
1
Answered by 7 years ago

Tick

Decide if it's the first time when it happens. This is as simple as remembering when it happened, and simply checking if it happened recently enough for you.

local time,x = 0,0
Mouse.MouseButton1Click:connect(function()
  local now = tick()
  if time + 5 > now then -- Last time was less than 5 seconds ago?
    x = x+1
  else
    x = 1
  end
  print(x)
  time = now
end)
0
This is lit fam thanks for teaching me :D Acryius 22 — 7y
Ad

Answer this question