Damage Humanoid Health with loop

Hello Developers! :slight_smile:, I currently did a kaioken transformation. And I’m trying to hurt the humanoid every 3 seconds with a loop. I tried it but it did not work for me, does anyone know the error?

  1. modes[“Kaioken x5”] = function(player, toggle, data, modeNumber, animation, flying)
  2. if toggle then
  3.  animationBind(animation)
     
     local aura = bindAura(assets.Kaioken20:Clone(), data.UpperTorso, true)
    
     
     bindAuraSound(assets.AuraLevelA:Clone(), data.UpperTorso, true)
     local aura = bindAura(assets.Kaioken21:Clone(), data.UpperTorso, true)
     
     while true do
     	local me = game:service'Players'.localPlayer
     	local ch = me.Character
     	local hum = ch:FindFirstChildOfClass'Humanoid'
     	
     	hum.Health -= 7
     	wait(3)
     end

:thinking:

modes["Kaioken x5"] = function(player, toggle, data, modeNumber, animation, flying)
    local Char = player.Character

    if toggle and Char and Char:FindFirstChild("Humanoid") then
        animationBind(animation)

        local aura = bindAura(assets.Kaioken20:Clone(), data.UpperTorso, true)

        bindAuraSound(assets.AuraLevelA:Clone(), data.UpperTorso, true)
        
        aura = bindAura(assets.Kaioken21:Clone(), data.UpperTorso, true)

        while Char.Humanoid.Health > 0.1 do
            Char.Humanoid.Health -= 7
            wait(3)
        end
    end
end)

We would appreciate it if you could provide more information on what errors you’re currently receiving

1 Like

could it be that u are on a server script cuz dis wont work

The humanoid is damaged, but the transformation does not fire, where should I put the loop? sorry i am using translator

modes[“Kaioken x5”] = function(player, toggle, data, modeNumber, animation, flying)
local Char = player.Character

if toggle and Char and Char:FindFirstChild("Humanoid") then
	animationBind(animation)

	local aura = bindAura(assets.Kaioken20:Clone(), data.UpperTorso, true)


	bindAuraSound(assets.AuraLevelA:Clone(), data.UpperTorso, true)
	local aura = bindAura(assets.Kaioken21:Clone(), data.UpperTorso, true)

	wait(1.285 / 2)
	
	
	

	if not flying then
		footRing(3, data, 1)
	end

	spawn(function()
		for i = 1, 10 do
			aura:Emit(3)
			wait(.2)
		end
	end)

	smallExplosion(data, true, BrickColor.new("Really red"))

	healthRatio(data.Humanoid, 100 * modeBoostModule[modeNumber])
	if player.Status.Fusion.Value == "true" then
		player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + player.Character.Humanoid.MaxHealth
	end 		
	if player.Status.Potara.Value == "true" then
		player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + player.Character.Humanoid.MaxHealth
	end 			

	wait(1)
	animation:Stop(.2)
	wait(.2)
	
	while Char.Humanoid.Health > 0.1 do
		Char.Humanoid.Health -= 7
		wait(3)
		end
	
	
else
	bindAura(nil, data.UpperTorso, false)
	bindAura(nil, data.UpperTorso, false)
	bindAuraSound(nil, data.UpperTorso, false)
	healthRatio(data.Humanoid, 100)
end

end