Getting a characters current animation thru script

Is there any way to get a character’s current playing animation and then modify its speed

Example: While the player’s character is touching a part ANY animation being played on the player’s character
Example 2: The player punches a part (obviously thru a previously made combat system) and the punch animation slows down

If what I’m trying to explain is hard to understand (It probably is) I’m sorry, my native language isn’t English

Animators have a method to do exactly this.

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local AnimationTrackArray = Humanoid.Animator:GetPlayingAnimationTracks() -- gives an array

Then you can just check if the animaton you want to change is playing.

for _, AnimationTrack: AnimationTrack in AnimationTrackArray do
    if AnimationTrack.Animation.AnimationId ~= "rbxassetid://"..[AnimationIDHere] then
       continue
    end

    AnimationTrack:AdjustSpeed(whatever) --This is the animation you want to change
end
1 Like

Thank you very much this helped a lot

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.