When I try to use my sword on NPCs it wont do damage. (the NPCs have humanoids)
Script:
local SwingAnim = script:WaitForChild("SwingAnimation")
local Debounce = false
local PlayersHit = {}
-- Welds
for i, Parts in pairs(Handle:GetChildren()) do
if Parts:IsA("BasePart") then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Parts
Weld.Part1 = Handle
Weld.Parent = Parts
end
end
-- Anim
script.Parent.Activated:Connect(function()
if Debounce == false then
Debounce = true
local Humanoid = script.Parent:WaitForChild("Humanoid")
local AnimTrack = Humanoid:LoadAnimation("SwingAnim")
AnimTrack:Play()
wait(1)
Debounce = false
end
end)
-- Damage
Handle.Parent:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= script.Parent.Parent then
if Debounce == true and PlayersHit[Hit.Parent] == nil then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(50)
PlayersHit[Hit.Parent] = true
wait(1)
PlayersHit[Hit.Parent] = nil
end
end
end)