Ok, so long story short, I'm trying to make a time stop function. I have no problem registering the hits, or dealing the damage, but when it comes to dealing damage after a timestop, the calls of the damage function are a problem. My current solution, while rudimentary, isn't as fast as I'd like it to be and it isn't very reliable either. I mean, it does the damage, but not even in the right order. Here is an example of what I mean. The damage should be applied instantly to all of the dummies (or at least quicker than it is already), going down the row from left to right. Instead, this is what happens: gyazo I won't post my code in detail because that isn't the focus of this question. I will replace it with some comments instead.
hitevent.OnServerInvoke = function(player, id, hitter, hittercframe, damage, voiceline, hum)
local hit = false
--finds a suitable humanoid within a region which is cast by the server
local registered = false
if hum and hum.Health > 0 and registered == false then
registered = true
hit = true
if game.Workspace.timestopped.Value == true then --this is the condition i want to be met
coroutine.resume(coroutine.create(function()
repeat wait() until game.Workspace.timestopped.Value == false
coroutine.resume(coroutine.create(function()
applydamage(player,id, hittercframe, hum, damage)
end))
end))
else
applydamage(player, id, hittercframe, hum, damage)
end
return hit
end
The problem is stacking all the damage calls at once. I even tried with two coroutines as you can see, and the problem still persists. I'm not sure if wait() is not precise enough or what, but as you can see from the gif, I can't keep it like this. Thank you for any help.

1 comment
When you've done checks for a humanoid, don't apply the damage yet. Instead, add the person to a list of people to be damaged. Afterwards, wrap a loop through that table inside of your repeat. There shouldn't be need for a coroutine, since (based on the gyazo you sent) application of damage is be near instantaneous.