How do I make players get stunned after being punched?

Hi I’m trying to add stun to my melee combat system for my fighting game but I’m wondering what is the best way to stun players after they’re hit, like in some of the combat systems I’ve seen. I was able to make it so the player cannot move for a second after being hit but I also want them to be unable to attack.

1 Like

What I would do is make the player who got hit have a walkspeed of 0, jump power 0, play a stun animation, play a sound effect, and enable some particle effects. But. This may be too much.

If you want the player to not attack others, I would add a boolValue and set it to true when the player can attack, and false when the player should not attack.
( This would require adding some scripting to the combat code you already have with an if statement. )

1 Like

Try this. You will have to add your own animation that plays, but here is a good starting point:

local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()

local stunPlayer = function()
   Controls:Enable(false)
   wait(3) -- Change this to amount of time you want the character to be frozen.
   Controls:Enable(true)
end
2 Likes

I searched the Roblox audio for stun sound effects. This was the only one that was really a “stunned sound”: stunned - Roblox

I would recommend making your own sound, but it cost robux to do so.

2 Likes

so the best way for me was to do

Humanoid.walkSpeed = 0
Humanoid.JumpPower = 0
Can Attack = false
--PlayAnim
wait(stuntime) 
--AnimStop
Humanoid.walkSpeed = 16
Humanoid.JumpPower = 50
Can Attack = true

you can fire the client and do this

1 Like