#🙇 Bowing Animation Script Bug (Still Need Help)

11 messages · Page 1 of 1 (latest)

fresh sparrow
#
local IDLEAnimation = Tool:WaitForChild("IDLE")
local BOWAnimation = Tool:WaitForChild("BOW")

local isEquipped = false
local holdingMouse = false
local idleTrack, bowTrack

local function getHumanoidAndLegs()
    local Character = Tool.Parent
    local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
    local rightLeg = Character:FindFirstChild("Right Leg")
    local leftLeg = Character:FindFirstChild("Left Leg")
    return Humanoid, rightLeg, leftLeg
end

local function toggleLegAnchoring(anchored)
    local _, rightLeg, leftLeg = getHumanoidAndLegs()
    if rightLeg then rightLeg.Anchored = anchored end
    if leftLeg then leftLeg.Anchored = anchored end
end

local function playAnimation(animation, looped)
    local Humanoid = getHumanoidAndLegs()
    if not Humanoid or not animation then return end

    local track = Humanoid:LoadAnimation(animation)
    track.Looped = looped
    track:Play()
    return track
end

local function stopAnimation(track)
    if track and track.IsPlaying then
        track:Stop()
    end
end

local function playReverse(track, onComplete)
    if track then
        track:AdjustSpeed(-1)
        local reverseDuration = math.max(0.1, track.Length - track.TimePosition)  

        task.delay(reverseDuration, function()
            if track.TimePosition <= 0 then
                if onComplete then
                    onComplete() 
                else
                    toggleLegAnchoring(false) 
                    playIDLEAnimation()
                end
            end
        end)
    end
end```
#
    stopAnimation(idleTrack)
    idleTrack = playAnimation(IDLEAnimation, true)
    toggleLegAnchoring(false)
end

local function playBOWAnimation()
    if holdingMouse then return end
    holdingMouse = true

    stopAnimation(bowTrack)
    bowTrack = playAnimation(BOWAnimation, false)

    toggleLegAnchoring(true)
    bowTrack.Stopped:Connect(function()
        if holdingMouse then
            bowTrack.TimePosition = bowTrack.Length
            bowTrack:AdjustSpeed(0) 
        end
    end)
end

local function stopBOWAnimation()
    if bowTrack then
        holdingMouse = false

        if bowTrack.TimePosition == bowTrack.Length and bowTrack.Speed == 0 then
            playReverse(bowTrack, function()
                toggleLegAnchoring(false) 
                playIDLEAnimation() 
            end)
        elseif bowTrack.IsPlaying then
            playReverse(bowTrack, function()
                toggleLegAnchoring(false)
                playIDLEAnimation()
            end)
        else
            toggleLegAnchoring(false) 
        end
    end
end

Tool.Equipped:Connect(function()
    isEquipped = true
    playIDLEAnimation()
end)

Tool.Unequipped:Connect(function()
    isEquipped = false
    stopAnimation(idleTrack)
    stopAnimation(bowTrack)
    toggleLegAnchoring(false)
end)

Tool.Activated:Connect(playBOWAnimation)
Tool.Deactivated:Connect(stopBOWAnimation)
#

Animation Script Bug

#

Animation Script Bug Help

#

@ping me for a response.

mortal capeBOT
#

🟢 25 ms

cyan ospreyBOT
#

studio** You are now Level 1! **studio

fresh sparrow
#

Animation Script Bug (Still Need Help)

#

🙇♀ Bowing Animation Script Bug (Still Need Help)