Stun Handler V2.1

Made a stun module that I can use over multiple scripts and I thought I could share it with anyone else who might find it useful too. Useful for combat games.

It is very easy to use. All you need to do is pass a humanoid object and the time you want the stun to last for (secs).

It saves the current WalkSpeed and JumpPower of the humanoid before setting them to 0.
If you try to stun a humanoid that is already being stunned, it will compare the remaining time of the previous stun with the new one. If the new stun duration is longer, the duration of the previous stun will be updated to the new one.

When a humanoid is successfully stunned, it will add an attribute named “Stunned” to the humanoid’s parent (generally the character).

If there are problems/ways to optimise, advice is much appreciated! Thanks.

Example

local StunHandler = require(path.to.module)

character:GetAttributeChangedSignal("Stunned"):Connect(function()
    print(character:GetAttribute("Stunned"))
end)

StunHandler.Stun(humanoid, 5) -->> Stuns the humanoid for 5 seconds

https://www.roblox.com/library/6448755875/Stun-Handler-V2

69 Likes

Thanks, this will be very useful!

2 Likes

Looks fine, however, why don’t you save old JumpPower like WalkSpeed?

humanoid.WalkSpeed = placeInTable["speed"]
humanoid.JumpPower = 50

There are games that have different JumpPower set, not 50.
Other than that, it looks fine, maybe you could improve it by making sure the WalkSpeed/JumpPower don’t get changed while you are stunned with a Humanoid Changed connection (make sure to disconnect when stun duration is over)

4 Likes

Thanks for the feedback!
I was already contemplating on saving the JumpPower but thanks for the tip.

About the humanoid changed connection, I didn’t even notice that problem until you mentioned it. Thanks a lot for the advice!

I’ve added the changes; if you’re willing, please let me know if there’s any problems with what I’ve done, thanks.

Version 2 released!
Made a lot of improvements on performance

does this stun work for things like combo stuns. For example, when you hit someone with a sword combo, they can’t move or do anything until the combo is over or is interrupted.

Yes, you will need to specify how long you want the stun to last though.

2 Likes

How would i detect if a player is stunned in a local script?

An attribute is added to the humanoid’s parent (generally the character)
In your local script you can listen to its change

character:GetAttributeChangedSignal("Stunned"):Connect(function()
    print(character:GetAttribute("Stunned"))
end)
1 Like

Looks nice! This post is more than just a cool creation, you may put it in #resources:community-resources :eyes:

I like that you used attributes!

2 Likes

Thank you!

I was considering posting it in #resources:community-resources but I wasn’t sure if it’s worthy of being there. :sweat_smile:

1 Like

Can you make an option to turn the stun on or off without duration because some of us might need this feature and i’m one of them.

So basically, this feature will ignore any incoming stuns (including current stuns) when until it’s off, and that’s it.

How do you use it? i dont understand. is it any instructions ?

Well i just used it and edited it because the owner doesn’t seem to update it anymore, so if you know how then you should too

i understand how to stun the player and require but in the local scipt i want to stop doing m1s.

Really useful module! However since its a resource its better to put it in #resources:community-resources .

Hey could any one answer how to use it in local script if i wanna like disable the debounce in the local script when people gets stunned.

sometimes players get permanently stunned (i was testing with 3 of my friends and we kept fighting then after a while the moves started to permanently stun whoever was hit instead of stunning for the duration i put.)
edit: nvm it was because the server script was inside of the tool so it would be deleted before the stun would be removed from the other player

1 Like

When I disable the script while the humanoid is still stunned, it becomes permanently stunned. Any ways to fix this?

edit: nevermind i found a alternate way (i have no common sense)

Is there a way to pair the stun with animations?