I'm trying to make a combo system that resets to the initial animation it started with if the player remains idle after attacking. It would go to 1,2,3,4,5 then reset back to 1; but if you were idle and stopped at 3 it would go 1,2,3 wait and back to 1.
But the local-script I have right now doesn't reset it at all, it just keeps going with the regular cycle of 1,2,3,4,5
local uis = game:GetService("UserInputService")
local repstorage = game:GetService('ReplicatedStorage')
local events = repstorage:FindFirstChild("Events")
local modules = repstorage:FindFirstChild("Modules")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
repeat wait() until player:HasAppearanceLoaded()
local current = 1
local cooldown = false
local startTime = tick()
local maxTime = 1.5
local animTable = {
"rbxassetid://04540124455",
"rbxassetid://04540153886",
"rbxassetid://04540429673",
"rbxassetid://4540628785" ,
"rbxassetid://4540931147"
}
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not char:FindFirstChildOfClass("Tool") and not cooldown then
cooldown = true
startTime = tick() --------TIMER SCRIPT[[
spawn(function()
if(tick() - startTime) > maxTime then
startTime = tick()
current = 1
print("waited too long, combo reseted to first animation")
end
end) ----------TIMER SCRIPT END]]
local hum = char:FindFirstChild("Humanoid")
local a1 = Instance.new("Animation")
a1.AnimationId = animTable[current]
local track = hum:LoadAnimation(a1)
track:Play()
track.KeyframeReached:Connect(function(frame)
if frame == "Hit" then
local part = Instance.new("Part")
end
end)
track.Stopped:Connect(function()
if current ~= #animTable then
current = current + 1
else
current = 1
end
print(current)
cooldown = false
end)
end
end)

2 comments
Are you using a loop? and maybe try setting Line 67 to 0 instead of false
Im not using a loop, also cooldown is a boolean for my debounce that dictates whether a player can hit again; so, i cant set that to 0