Help with creating script HasPedBeenDamagedByWeapon

I would like to create a script that works like this but I can’t seem to figure it out. I have borrowed the timer.

Citizen.CreateThread(function()
while true do
Wait(0)
if HasPedBeenDamagedByWeapon(GetPlayerPed(-1), GetHashKey(“weapon_knife”), -1716189206) then
TaskStartScenarioInPlace(player, “move_crawlprone2crawlfront”, 0, false)
end
end
end)

Citizen.CreateThread(function()
local time = 10
while (time ~= 0) do
Wait( 1000 )
time = time - 1
end
SetEntityHealth(GetPlayerPed(-1), 0)
end)

“A script that works like this” can you explain that a bit more? As that’s not really useful for trying to help because we don’t know what you want to achieve.

I want to make a script that makes you crawl when you get stabbed by a knife in maybe 1 minute and you have time to call paramedic to make them heal you. If not you will die and get the ambulancejob hospital timer