Clock that resets [2D Fighting Game]

Hello, I’ll try to keep it short and simple:

Main Problem:

The main problem is that I want to make a clock to change a player’s “Stunned” state back to “Idle”, but that clock should reset if the player get’s stunned or hit again, how can I achieve this?

I don’t have any code to showcase proof and implementation because I purely don’t know how to start this as it’s something I’ve never done before.

I did something like this some time ago by using a number value and tick()

make a number value in the humanoidrootpart, then follow this script:

local function stun(character)
 local root = character.PrimaryPart
 local humanoid = character.Humanoid
 local tickvalue = root.tickvalue --or whatever you named the number value
 tickvalue.Value = tick()
 local currenttick = tickvalue.Value --basically it sets a value that starts when you call the function the first time
 humanoid.WalkSpeed = 0 --I used walkspeed and jumppower here but you can use whatever you like
 humanoid.JumpPower = 0
 task.wait(5)
 if tickvalue.Value == currenttick then -- it checks if the value changed, if it did then it won't do anything
  humanoid.WalkSpeed = 16
  humanoid.JumpPower = 50
 end
end
1 Like

Sorry for the late reply!

Have you tried looking at any videos on youtube or any other devforums for a stopwatch type system?

I have a good example of: How to make a timer and stopwatch

in order to stop the timer in the link posted above, you can always just pause the tween…and then restart the tweenInfo to what you are wanting, this also allows for a quicker and much easier way to change time and display it since you can adjust everything!

YES, This was the solution. Thank you so much!

I had to use task.spawn to implement this on a separate thread but thank you so much.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.