handle.Touched:connect(function(hit)
if not pause2 then
pause2 = true
if Mouse.Button1Down then
if humanoid and hit and not hit:isDescendantOf(person) and Mouse.Button1Down then
local target = hit.Parent:FindFirstChild("Humanoid")
print("Target variable added.")
target:TakeDamage(damage)
print("Target took damage!")
wait(0.7)
pause2 = false
print("Hit Function Finished!")
else
end
end
end
end)
I can't really figure out why this is happening. The error happens on the line that says "target:TakeDamage(damage)". Any help?

2 comments
You should rather use hit:FindFirstAncestorOfClass("Model").Humanoid because if for example an accessory's part fired the event, you would be looking for the Humanoid under an accessory.
Whenever I do that, an error fires on line 06 saying "attempt to index a nil value"