How to properly manage and change walkspeed when attacking

Hello im amaro, and im really need help to manage the walkspeed on my combat system.
I having problem to make the player slow when attacking, and here is the way how i make the player slow down

function attack()

Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
Task.wait(1)
--code stuff
Task.wait(0.1)
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50

end

Just to remind you, my game is like ummh lets put it like saitama battlegrounds or AUT, with m1 and cool attacks.

And i have a value that is used as a debounce we can say to not spamming all the attacks at once, may could have use on this problem.
But anyways that my problem with walkspeed and idk how to start

2 Likes

Sooo… What exactly is the problem?

…i dont know how to slow down the character when attacking without the walkspeed being changed to normal and then idk slowed down

You can use like this:

Humanoid.WalkSpeed -= Your Number -- reducing walkspeed
Humanoid.JumpPower = 0 -- This can be stay same if you want
task.wait(1)
--code stuff
task.wait(0.1)
Humanoid.WalkSpeed += Your Number -- increasing walkspeed to normal
Humanoid.JumpPower = 50
1 Like

I mean seems good, but idk im insocured when do that method, is wanna slow the movement of the player while playing, because if the player do combos and do multiple attack using this method, when he is done and idk having the cooldowns of each attack is wanna have take a long way to idk restore the original movement? Idk but i wanna try later