#how to cancel animation from another section of script where the loaded animation hasn't been define

1 messages · Page 1 of 1 (latest)

tribal obsidian
#
    local character = player.Character or player.CharacterAdded:Wait()
    local hum = character:WaitForChild("Humanoid")
    local Animator = hum:WaitForChild("Animator")
    local bandageAnim = Instance.new("Animation")
    bandageAnim.Parent = Animator
    bandageAnim.Name = "bandageAnim"
    bandageAnim.AnimationId = "rbxassetid://124100725517756"
    
    print(player, "Is using the bandage tool!")
    
    local bandageAnimTrack = Animator:LoadAnimation(Animator:FindFirstChild("bandageAnim"))
    
    bandageAnimTrack:Play()
    
end)

BandageCancelled.OnServerEvent:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local hum = character:WaitForChild("Humanoid")
    local Animator = hum:WaitForChild("Animator")
    local bandageAnim = Animator:FindFirstChild("bandageAnim")

    print(player, "Cancelled the bandage tool!")
end)```

how can i make the animation stop from the bandagecancelled section?