Log in to vote

[CLOSED]Detect how much time has passed since input?

Asked by 1 month ago
Edited 1 month ago

Hello! I am making a combat script, where you can throw 3 punches until your combo resets. I have made this many times before, but I want to implement something new into it. I want to make the combo counter reset after a certain number of seconds have passed. I'm not too good with tick(), so I don't understand how to do this. Here's an example of what I want:

local uis = game:GetService("UserInputService")
local char = script.Parent
local combo = 1 
local debounce = false 
local remote = game:GetService("ReplicatedStorage").Remotes.Combat
local key = Enum.UserInputType.MouseButton1
uis.InputBegan:Connect(function(input, gpe)
local currentTime = tick()
if gpe then return end
if input.KeyCode == key then 
if not debounce then 
debounce = true
combo += 1 
local timePassed = tick() - currentTime
if timePassed >= 1 then 
combo = 1 
debounce = false    

This is just an example, Im sure this wouldnt work. Please help!

Answer this question