local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("RaycastHitboxV4"))
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local Tool = script.Parent
local Motor6D = Tool:FindFirstChild("Motor6D")

local Character = script.Parent.Parent
local Hitbox = RaycastHitbox.new(Character)


local variables = {
	damage = 30,
	hitboxTime = 0.5
}

if not Motor6D then
    warn("Motor6D not found in Tool")
    return
end

local function loadAnimation(animationName)
    local animationFolder = ReplicatedStorage:FindFirstChild("Animations")
    if not animationFolder then
        warn("Animations folder not found in ReplicatedStorage")
        return nil
    end

    local toolAnimations = animationFolder:FindFirstChild(Tool.Name)
    if not toolAnimations then
        warn("Tool animations not found in Animations folder")
        return nil
    end

    local animation = toolAnimations:FindFirstChild(animationName)
    if not animation then
        warn("Animation '" .. animationName .. "' not found for tool " .. Tool.Name)
        return nil
    end

    return animator:LoadAnimation(animation)
end

local animations = {
    equip = loadAnimation("Equip"),
    idle = loadAnimation("Idle"),
    slash1 = loadAnimation("Slash1"),
    slash2 = loadAnimation("Slash2"),
    slash3 = loadAnimation("Slash3")
}

local isEquipped = false
local slashIndex = 1
local slashAnimations = {"slash1", "slash2", "slash3"}

Tool.Equipped:Connect(function()
    if not isEquipped then
        isEquipped = true
    else
        warn("isEquipped bool was true before equipped!")
    end

    local rightArm = character:FindFirstChild("Right Arm")
    if not rightArm then
        warn("Right Arm not found in character")
        return
    end

    local rightGrip = rightArm:FindFirstChild("RightGrip")
    if rightGrip then
        rightGrip:Destroy()
    end

    Motor6D.Part0 = rightArm

    if animations.equip then
        animations.equip:Play()
    end
    if animations.idle then
        animations.idle:Play()
    end
end)

Tool.Unequipped:Connect(function()
    isEquipped = false
    for _, animation in pairs(animations) do
        if animation and animation.IsPlaying then
			animation:Stop()
			Hitbox:HitStop()
        end
    end
end)

Tool.Activated:Connect(function()
    if isEquipped then
        for name, animation in pairs(animations) do
            if name ~= "idle" and animation and animation.IsPlaying then
                animation:Stop()
            end
        end

        local currentSlash = animations[slashAnimations[slashIndex]]
        if currentSlash then
			currentSlash:Play()
			Hitbox:HitStart()
			task.wait(variables.hitboxTime)
			Hitbox:HitStop()
        else
            warn("Slash animation not found: " .. slashAnimations[slashIndex])
        end

        slashIndex = (slashIndex % #slashAnimations) + 1
    else
        warn("Tool activated while not equipped")
    end
end)



Hitbox.OnHit:Connect(function(hit, humanoid)
	local hitCharacter = hit.Parent.Character

    while hitCharacter and hitCharacter.Parent do
        hitCharacter = hitCharacter.Parent
    end

    if hitCharacter ~= Character then
        humanoid:TakeDamage(variables.damage)
    end
end)


i want a 1 second delay between swings. dont give me the whole code, just tell me what to add or modify.