So I'm making a combat system where hitting a player causes them to be stunned for 1 second, the problem I don't know how I'd go about renewing the stun time each time the player is hit.
As a result the player ends up not being stunned when they should be after multiple hits.
It's a module script, so I can't add a global denounce as its available to all players.
This devforum post details the same problem I'm having but I don't really understand the answer given: https://devforum.roblox.com/t/player-stun-difficulties/334882
This is a simplified version of the code:
Stun = {}
function Stun.StunTarget(Target)
Target.Humanoid.WalkSpeed = 0
wait(1)
Target.Humanoid.WalkSpeed = 16
end
return Stun

2 comments
He's saying instead of having to use a global debounce, you can track the players in a table and each player can have their own respective debounce.
You're adding too much then there is supposed to be.