How to make it if enemy take damage

how to make it if enemy take damage
this is my script:

		local connection
							connection = enemy.Humanoid.HealthChanged:Connect(function()
								enemy.Humanoid.Health = prevhp
							end)
							 
							repeat
								wait(0.5)
								enemy:WaitForChild("UsingMove").Value = true
								enemy.HumanoidRootPart.Anchored = true
							until game.Workspace.WorldTimestop.Value == false
							tsscript:Destroy()
							
							local tsscripts = script.LocalScript2:Clone()
							tsscripts.Parent = enemys.Backpack
							connection:Disconnect()	
							
							enemy.Humanoid:TakeDamage(math.random(10,30))
1 Like