If fired on target, it would slow the target down, if fired again, the length should like reset, but it doesn’t do it. any suggestions?
Code:
script.Parent.Stun.Event:Connect(function(target,length)
target.StatsFolder.HitStun.Value = true
coroutine.wrap(function()
for xd = 1,4 do
target.Humanoid.WalkSpeed = 0.25
target.Humanoid.JumpPower = 0
wait(0.05)
end
end)()
delay(length,function() -- completing after waitTime
if target.StatsFolder.HitStun.Value == true then -- check if current stun is under this thread
print("still had id reset")
target.StatsFolder.HitStun.Value = false
target.Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
target.Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower
else
print("id not found") -- current stun is not managed by current thread skip
end
end)
end)
This part of the code executes during the execution of the next part of the code. But wait, the next part has delay so this part executes 0.75 seconds before the next part.