Help with npc not dying

When my player has more strength then the npcs health it does not die. does anybody know why?
i will provide code if needed. and health goes into minus.

local Debounce = false
local ChangeStateNumber = 0





local Sword_Module = {}



function Sword_Module.Slash(ToolName, PPC,plr)
	local char = workspace:WaitForChild(plr.Name)
	local Humanoid = char:WaitForChild("Humanoid")
	
	if not Debounce and ChangeStateNumber == 0 then
		Debounce = true
		ChangeStateNumber = 1
		
		local blacklist = {}
		
		game.Players:FindFirstChild(plr.Name).leaderstats.Power.Value += PPC.Value
		for i, basepart in pairs(char:GetChildren()) do
			if basepart:IsA("BasePart") then
				table.insert(blacklist, basepart)
			end
		end
		
		local raycastparams = RaycastParams.new()
		
		raycastparams.FilterType = Enum.RaycastFilterType.Blacklist
		raycastparams.FilterDescendantsInstances = blacklist
		
		
		for i,v in pairs(workspace.Mobs:GetDescendants()) do
			if v:IsA("Model")  then
				local direction = v.HumanoidRootPart.Position - char.HumanoidRootPart.Position
				local raycastresuly = workspace:Raycast(char.HumanoidRootPart.Position,direction, raycastparams)
				if raycastresuly.Instance and  raycastresuly.Instance.Parent:FindFirstChildOfClass("Humanoid") then
					if raycastresuly.Distance < 5 and raycastresuly.Instance.Parent.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
						raycastresuly.Instance.Parent.HumanoidRootPart.Hit:Emit(1)
						workspace.BladeStab:Play()
						raycastresuly.Instance.Parent.Humanoid:TakeDamage(plr.leaderstats.Power.Value)
						raycastresuly.Instance.Parent.Humanoid.Animator:LoadAnimation(script.Hit):Play()
					end
					
				end
			end
		end
		script["sword slash"]:Play()
		Humanoid.Animator:LoadAnimation(script.Slash1):Play()
		script["Sword Swish 102 (SFX)"]:Play()
		wait(0.6)
		Debounce = false
		ChangeStateNumber = 0
	end
		
		
end

return Sword_Module


here is the code that damages the npc

Is the code in a localscript? If it is then that would be the problem. You could use a remote event to damage the npc through a serverscript.

It appears to be a module script. Unless it is being executed in a LocalScript, that is not the issue.

Can you show me the properties of the humanoid (the health included), and the properties of the power value, and potentially a video if you can?

It was late and i didn’t read it very well lol. Yeah it looks like its a module script.

1 Like

fixed the issue now thanks though!

2 Likes

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