CCCPaste

New ToolScript (Tool + Stacks)

local Tool = script.Parent
local uses = 0
local maxUses = 2
local cooldown = 0-- Cooldown time in seconds
local animationId = 15036314680
local canUse = true  -- Flag to track if the tool can be used

-- Load the animation
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://" .. animationId

-- Connect the animation to the Humanoid
local function playAnimation(humanoid)
	local track = humanoid:LoadAnimation(animation)
	track:Play()
end

Tool.Activated:Connect(function()
	if canUse and uses < maxUses then
		local h = Tool.Parent:FindFirstChild("Humanoid")
		if h then
			canUse = false  -- Set the flag to prevent spamming
			playAnimation(h)  -- Play the animation
			h.Health = h.Health + 15
			uses = uses + 1
			wait(cooldown)  -- Wait for the cooldown period
			canUse = true 
			-- Reset the flag
			if uses == maxUses then
				Tool.stacks.Value -= 1
				if Tool.stacks.Value == 0 then
					Tool:Destroy()
				end
			end
		end
	end
end)