Honestly I am completely stumped by this. I am trying to make a system where after a player is downed, they gradually loose health until they die, or until they are revived by another player. Problem is, the script is malfunctioning and it will loose health by one, then two, then six, then the player is dead. H e l p.
character.Humanoid.HealthChanged:Connect(function()
if character.Humanoid.Health <= 15 then
character:FindFirstChild("Health").Disabled = true
while character.Humanoid.Health <= 15 do
local dt = wait(2)
character.Humanoid.Health = math.min(character.Humanoid.Health - 1, character.Humanoid.MaxHealth)
character.Humanoid.HealthChanged:Wait()
end
elseif character.Humanoid.Health > 15 then
character:FindFirstChild("Health").Disabled = false
end
end)
local oldHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(newHealth)
if newHealth <= oldHealth then
return
else
oldHealth = newHealth
--Do code.
end
end)