Interrupt time stop from damage

I am trying to make a script that waits 2 seconds before time is stopped. However, i want the time stop process to be interrupted if the player takes damage.

You can use a Loop that checks if the Player Humanoid Health is smaller that the last time that it was checked.

local Player = "" -- Player Location here
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild("Humanoid")

local LastHealth = Humanoid.Health
while true do
    if LastHealth < Humanoid.Health then
        print("Damage!")
        break -- stops the loop
    end
end
1 Like

I think this is better

local LastHealth = Humanoid.Health
Humanoid.HealthChanged:Connect(function()
if Humanoid.Health < LastHealth then – Character Damaged
– Do Stuff
end
LastHealth = Humanoid.Health
end)

sorry I dont know how to edit the color or stuff like that so its kinda messy

2 Likes

After making some slight changes, it works beautifully!