Electric Ball instant killed King Drooling Zombie (Problem)

Hello, i gotten a problem with my code here, so i tried to Nerf Eletric Ball with a code

script.Parent.Touched:Connect(function(hit)
	if script.Parent.Velocity.Magnitude >= 120 then
		if hit.Parent:FindFirstChildOfClass("Humanoid") then
			if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
				if hit.Parent:FindFirstChildOfClass("Humanoid").PlatformStand == false then
					hit.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
					hit.Parent:FindFirstChildOfClass("Humanoid").Health = hit.Parent:FindFirstChildOfClass("Humanoid").Health - script.Parent.Velocity.Magnitude/75000000000
				end
				script.Parent.HitWhileSpeeding:Play()
				script.Parent.HardImpactSpeeding:Play()
				script.Parent.ShockHealth.Value -= math.floor(script.Parent.Velocity.Magnitude/25)
				script.Parent.Combo:Fire()
				local explosion = Instance.new("Explosion")
				explosion.Position = hit.Position
				explosion.BlastRadius = 0
				explosion.BlastPressure = 0
				explosion.ExplosionType = Enum.ExplosionType.NoCraters
				explosion.Parent = workspace
				wait(3)
				hit.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
			end
		elseif script.Parent.Velocity.Magnitude >= 40 then
			if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
				hit.Parent:FindFirstChildOfClass("Humanoid").Health = math.floor(script.Parent.Velocity.Magnitude/200)
			end
		end
	end
end)

but for Some Reason it just instant Killed King Drooling Zombie

for example:

the Health Bar Disappeared means King Drooling Zombie Died

any solutions to fix intsant-kill issues for My Eletric ball? let me know.

1 Like

Could it be that the ball is hitting the king many times in a row?

it maybe does, but i need solutions for Eletric ball actually.

Try printing out:

script.Parent.Velocity.Magnitude/75000000000

Also you can just use

Humanoid:TakeDamage(script.Parent.Velocity.Magnitude/75000000000)

Nope it did not work. it just still instant kills the King Zombie

It’s instant killing the zombie because it detects a touch multiple times every second. To fix this you need to implement a rebound.

They work like this:

local rebound = false -- Declare the variable outside of your function

local function coolFunction(epicParameter)
   if rebound then return end -- Returns the function if the rebound is enabled.
  rebound = true
  -- Epic function contents --
  rebound = false --Once the function is done it's disabled so the function can run again.
end

Oh my god, it works! thank you so much :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.