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