Animation Plays When Activated

local Tool = script.Parent
local Handle = Tool.Handle
local Sound = game.Workspace.MiningSounds.OreHit

local Animation = Tool.Animation
local AnimationTrack

local function ResetAnimation()
    if not game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent) then return end
    AnimationTrack = Tool.Parent.Humanoid.Animator:LoadAnimation(Animation)
end

ResetAnimation()
Tool:GetPropertyChangedSignal("Parent"):Connect(ResetAnimation)

local Damage = 25
local Cooldown = 1
local Usable = true

local function CreateHitbox()
	
	local Hitbox = Instance.new("Part")
	Hitbox.Parent = game.Workspace
	Hitbox.Name = "Hitbox"
	
	Hitbox.Size = Vector3.new(2.7, 4, 2)
	Hitbox.Anchored = false
	Hitbox.CanCollide = false
	
	Hitbox.CFrame = Handle.CFrame * CFrame.new(-1.4,0,-2)
	
	
	Hitbox.Touched:Connect(function(hit)
		
		local Mineable = hit
		
		if Mineable and Mineable:FindFirstChild("Health") then
			
			Mineable:FindFirstChild("Health").Value -= Damage
			Sound:Play()
		end
	end)
end


Tool.Activated:Connect(function()
	
	if Usable == true then
		
		
		CreateHitbox()

			Usable = false
            AnimationTrack:Play()
			task.wait(Cooldown)
			Usable = true
		end
end)