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
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!