Part not registering?

ok so im making an axe where u can chop down trees
it damages other players as well
but it wont register the tree when trying to hit it using a touch function
i get no errors
and ive asked around
and im just absolutely mind boggled at this point so once again i come to the dev forum

local tool = script.Parent
local axeActive_db = true
local activeHB = true
local hits = 0
local hitsN = math.random(tool.Hits.MinValue,tool.Hits.MaxValue) -- this is an intconstrainedvalue
tool.Activated:Connect(function()
	if axeActive_db == true then
	axeActive_db = false
	local animation = tool.Swing
	local Character = tool.Parent
	local player = game:GetService("Players"):GetPlayerFromCharacter(Character)
	

	local humanoid = player.Character:FindFirstChild("Humanoid")
	local axeSwing = humanoid:LoadAnimation(animation)
	local Swung = script.Parent.Swung
	local hitbox = script.Parent.AxeHitBox
	local coco = nil
	coco = hitbox.Touched:Connect(function(hit)
		if activeHB then
			activeHB = false
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent.Humanoid:TakeDamage(5)
				script.Parent.HitPlayer:Play()
			elseif hit.Parent.Name == "Log" then
				hits = hits + 2
				tool.Hit:Play()
				if hits >= hitsN then
					tool.Fall:Play()
					hits = 0 
					player.Data.Logs.Value = player.Data.Logs.Value + math.random(5,15)
					player.Data.Leaves.Value = player.Data.Leaves.Value + math.random(5,20)
						for i,v in pairs(hit.Parent:GetChildren())do
							if v:IsA("BasePart") then
								v.Transparency = 1 
								v.CanCollide = false
								wait()
						end
					end	
				
				end
			end
			wait(.5)
			activeHB = true
		end
	end)
	
	Swung:Play()
	axeSwing:Play()
	
	wait(.5)
	axeActive_db = true
	coco:Disconnect()
	coco = nil
	end
end)
1 Like

it damages players completely fine, but wont register the tree as being hit

i realized i forgot to load the other animations to humanoid, this could potentially be the problem, but i doubt it, will let u guys know

i have found why this wasnt working, it was because i said

elseif hit.Parent.Name == "Log" then

but i changed it to

elseif hit.Parent:FindFirstChild("Log") then

and that is what fixed it, thanks for taking your time to read tho