I am trying to make a combat that when you don’t click in like 1.5 seconds, the combo resets. I have tried looking on other fourms, but I can’t seem to figure out how to do this. I have tried to do this myself, but combo won’t reset after certain amount of time.
local ServerEvent = script.Parent:FindFirstChild("ServerEvent")
local UserInputService = game:GetService("UserInputService")
local tool = script.Parent
local idleAnim = tool:WaitForChild("CombatIdle")
local blockAnim = tool:WaitForChild("Block")
local combo1 = tool:WaitForChild("Combo1")
local combo2 = tool:WaitForChild("Combo2")
local combo3 = tool:WaitForChild("Combo3")
local hitAnim = tool:WaitForChild("GettingHit")
local equipped = false
local canAttack = true
local combo = 0
local timeUntilComboResets = 1.5
local lastTimeClicked = tick()
local PunchTime = 0.3
tool.Equipped:Connect(function()
equipped = true
character = tool.Parent
isPlayerBlocking = character:FindFirstChild("isPlayerBlocking")
humanoid = character:FindFirstChild("Humanoid")
end)
tool.Activated:Connect(function()
if equipped and isPlayerBlocking.Value == false and canAttack == true then
combo = combo + 1
print(combo)
if combo == 1 then
combo1Track = humanoid:LoadAnimation(combo1)
combo1Track:Play()
canAttack = false
wait(0.3)
canAttack = true
elseif combo == 2 then
combo2Track = humanoid:LoadAnimation(combo2)
combo2Track:Play()
canAttack = false
wait(0.3)
canAttack = true
elseif combo == 3 then
combo1Track:Play()
canAttack = false
wait(0.3)
canAttack = true
elseif combo >= 4 then
combo3Track = humanoid:LoadAnimation(combo3)
combo3Track:Play()
combo = 0
canAttack = false
wait(0.3)
canAttack = true
end
end
**local CurrentclickTime = tick() - lastTimeClicked**
** print(CurrentclickTime) **
** if CurrentclickTime >= CurrentclickTime + timeUntilComboResets then**
** combo = 0**
** print(CurrentclickTime)**
** print("Combo Reset")**
** lastTimeClicked = tick()**
** end**
end)
tool.Unequipped:Connect(function()
combo = 0
equipped = false
character = nil
isPlayerBlocking = nil
humanoid = nil
end)