I want to make it so when you stop clicking for 1 second (or more) it resets the combo
mouse.Button1Down:connect(function() if cooldown == true then return end if combo == 0 then cooldown = true combo = 1 print("first m1") m1:Play() wait(.3) game.ReplicatedStorage.Dmg:FireServer(leftarm,5,.8) wait(.47) cooldown = false elseif combo == 1 then cooldown = true combo = 2 print("second m1") m2:Play() wait(.1) game.ReplicatedStorage.Dmg:FireServer(rightarm,5,.3) wait(.19) cooldown = false elseif combo == 2 then cooldown = true combo = 3 print("third m1") m3:Play() wait(.1) game.ReplicatedStorage.Dmg:FireServer(leftarm,5,.3) wait(.19) cooldown = false elseif combo == 3 then cooldown = true combo = 0 print("fourth m1") m4:Play() wait(.2) game.ReplicatedStorage.Dmg:FireServer(leftleg,8,.3) wait(1.5) cooldown = false end end)
Add a while true loop running in a different thread so as not to yield the current thread in case you want code Fter that. Inside this while true do loop, check every second to see if the value was the same as last time, if it is, then that means nothing was added to the combo meaning it should end.
Example of running code in another thread, basically running multiple code at once:
Spawn(function() --code end)
So to do all of this would be something like:
Spawn(function() lastCombo = 0 While true do wait(1) --always wait 1 second If combo == lastcombo then -- checks if combo was same as it was a second ago combo = 0 -- cancels/resets combo if it was the same meaning the combo hasn't increased end lastCombo = combo -- setting the last combo then restarting loop which waits a second before executing the check again. end end)
Hope this helps:3