When the player gets hit, they begin bleeding for some time, however, it takes some time for the player to stop bleeding. Because of this and the fact that players can get hit multiple times, multiple loops will be created when the player is hit multiple times, resulting in this problem where the different loops will interrupt each other when setting the health of the player.
What I need to do is, if the player gets hit again, the script should do the following things:
- Stop the current loop when player is hit again
- Add the damage from the previous loop to the damage of the new loop, so stacking the damage on every hit
Here’s a simplified example of what I’m doing (server side)
-- Remote event fires to server
local co = coroutine.create(function()
local Diff = CurrentBlood - NewBlood
for blood = CurrentBlood, NewBlood, -1 do
health = blood
task.wait(BleedRate / Diff)
end
end)
coroutine.resume(co)
Bump