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.
Here's an idea I came up with:
local CallCount = 0 local TimeStopped = workspace.timestopped function Print() print("Test") end script.Parent.MouseClick:Connect(function(player) CallCount = CallCount + 1 if TimeStopped.Value == true then for i = 0, CallCount do Print() end end end)