So I created a “hit detect” script inside of my enemy’s AI script. What it’s supposed to do is wait until the enemy has been attacked. The script works perfectly in Studio but when I play it “In-game”, I get this:
Attempt to index nil with Value (Line 29)
Here’s how the AI’s organized:

And here is the script:
EnemyCharacter:FindFirstChild("HumanoidRootPart").Touched:Connect(function(hit)
if not canBeDamaged then
return
end
if hit.Parent:FindFirstChild("Humanoid") then --Checks to see if the player is a humanoid
local PlayerBodPts = { --All parts that the player uses to hit
hit.Parent:FindFirstChild("Left Arm"),
hit.Parent:FindFirstChild("Right Arm"),
hit.Parent:FindFirstChild("Right Leg")
}
local HitConfig = hit.Parent:FindFirstChild("HitConfig")
print("Okay dude... :/")
for i,v in pairs(PlayerBodPts) do
if hit.Parent:FindFirstChild("isAttacking").Value then --Line 29
Is this because of a bug or an error I made? Answers are welcome! 