I am using the TakeDamage() function in a tool to damage NPC humanoids. These humanoids only have a head, string value, bool value, and Humanoid object.
When using this function the humanoid does not take damage.
If it is something I am doing wrong then maybe you can help me.
Here is my script.
local Tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local isEquipped = false
function attack(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
print("attack")
if human then
print("human")
human:TakeDamage(10)
end
end
function swordUp()
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,1)
end
function swordOut()
Tool.GripForward = Vector3.new(0,0,1)
Tool.GripRight = Vector3.new(0,-1,0)
Tool.GripUp = Vector3.new(-1,0,0)
end
script.Parent.Equipped:connect(function()
isEquipped = true
end)
script.Parent.Unequipped:connect(function()
isEquipped = false
end)
mouse.Button1Down:connect(function()
if isEquipped == true then
swordOut()
wait(0.1)
swordUp()
end
end)
script.Parent.Handle.Touched:connect(attack)
Both print statements inside my attack function print.
