local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local flesh = handle:WaitForChild("Hit")
local blade = tool:WaitForChild("Blade")
local detect = tool:WaitForChild("CanAttack")
blade.Touched:connect(function(hit)
if detect.Value == true then
local hum = hit.Parent:FindFirstChild("NPC")
if hum then
--[[
for i,v in pairs(hit.Parent:GetChildren()) do
if v:IsA("IntValue") then
v:Destroy()
end
end
local kill = Instance.new("IntValue",hit.Parent)
kill.Name = script.Parent.Parent.Name
--]]
detect.Value = false
flesh:Play()
hum:TakeDamage(4)
wait(1)
detect.Value = true
end
end
end)
When the blade of the sword (a part) hits a NPC, it will check for the NPC's humanoid which is named "NPC" so that players can't kill each other. If it finds it, it will do damage to the NPC. The script works in studio but not in a real game with no errors.

2 comments
Try putting it into a localscript instead of a normal script.
Didn't work.