Help with stun [Combat]

Hello, So I am currently working on a combat script but i dont know how to make a proper stun script.
Here’s what i have tried:

--hit
stun = true
task.wait(1)
stun =  false
--Problem: the wait function doesnt reset and if multiple comboes overwrite each other the stun will activate multiple times instead of once.
 --hit
stun = true
task.wait(1)
stun = false
while stun do
--stun the player
task.wait(1)
--stop stunning the player
end
--same issue

Every time you get hit you’re setting “stun” to true, so you end up spamming it.

One way to fix this would be creating a variable then only letting another stun happen if the previous one is already over.

1 Like

Thank you so much, i figured out i could just use a boolvalue etc