Damage script instant-kills

Why is this script instant-killing the player when enabled?

local character = script.Parent

local burnSound = script.Burning
burnSound.Parent = character.HumanoidRootPart
burnSound:Play()


while script.Enabled == true and wait(1) do

	character.Humanoid:TakeDamage(5)

end
1 Like

script should be like this

while true do
  wait(1)
  character.Humanoid:TakeDamage(5)
end
while script.Enabled == true  do
task.wait(1)
	character.Humanoid:TakeDamage(5)

end

What @D9m9nt9d Said but including the script Enabling part

The loop doesn’t need to have wait nested. I just tested the code myself, with the exception of sound, and it worked fine for me. Not sure what would be causing it to seemingly instantly kill the player. Perhaps there’s more code that was omitted or conflicting code? Maybe other scripts that also damage the player? You also don’t need to check that the script is enabled, as disabling it will stop the loop.

That isn’t needed as disabling a script breaks all loops and disconnects all events.