hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= player.Character and not hit.Parent:FindFirstChild("Value") then
hit.Parent.Humanoid:TakeDamage(25)
local value = Instance.new("BoolValue")
value.Parent = hit.Parent
wait(0.5)
value:Destroy()
end
end)
NPC does not take damage when this script is triggered
Can you show the guts of your npc, is the humanoid named ‘Humanoid’?
also, maybe show a screenshot of where the hitbox is (if its inside another block it might not trigger a hit)
also, the original code you posted, can be a bit cleaner with attributes
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= player.Character and hit.Parent:GetAttribute("Value") == nil then
hit.Parent.Humanoid:TakeDamage(25)
hit.Parent:SetAttribute("Value",true)
wait(0.5)
hit.Parent:SetAttribute("Value",nil)
end
end)
hitbox.Touched:Connect(function(hit)
print("touched")
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= player.Character and not hit.Parent:FindFirstChild("Value") then
print("Damaging")
hit.Parent.Humanoid:TakeDamage(25)
local value = Instance.new("BoolValue")
value.Parent = hit.Parent
wait(0.5)
value:Destroy()
end
end)
hitbox.Touched:Connect(function(hit)
print(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") then print("1")
if hit.Parent ~= player.Character then print("2")
if hit.Parent:GetAttribute("Value") == nil then print("3")
if hit.Parent:FindFirstChild("Humanoid") ~= nil then print("4")
end hit.Parent.Humanoid:TakeDamage(25)
hit.Parent:SetAttribute("Value",true)
print(hit.Parent:GetAttribute("Value"))
wait(0.5) -- task.wait(0.5)
hit.Parent:SetAttribute("Value",nil)
print("5")
end
end
end
end)