How do i reset the cooldown counter if another stun has been added

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Basically, in my fighting game there’s stuns, and they work like this: every player has IsStunned BoolValue inside their character and it stuns them and dosen’t let them do anything. In the script where i create hitboxes, i have Stun(bool) and StunDuration, and if the stun is true it sets their IsStunned To true, but the problem is when the duration runs out it immediatly sets their IsStunned To false, but i need it so if another stun had been activated on the player, it renews their timer.

  2. What is the issue? Include screenshots / videos if possible!
    What is happening right now is that if you apply the stun 1 time it works fine, but if i apply stun while the player is stunned, when his previous stun runs out it sets it IsStunned To false and dosen’t wait until the second is stun is also finished.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have checked a lot of things online and on the forum and can’t find a solution that will work for me.
    Heres the part, how would i go about making it that it renews the timer if another stun has been added? (btw sorry if this post is bad, first time posting)

if Stun == true then
						local StunTimeLeft = StunDuration
						local EnemyCharacter = Humanoid.Parent
						local StunBool = EnemyCharacter:WaitForChild("IsStunned")
						
						StunBool.Value = true
						
						if StunDuration then
							
							task.delay(StunDuration, function()
								StunBool.Value = false
							end)
						else
							task.delay(2, function()
								if StunBool.Value == true then
									return
								end
								StunBool.Value = false
							end)
						end
					end
1 Like

I used a stun module from the toolbox, if anybody needs this here it is Stun Handler V2.1