So I made another post earlier where I had problems with the function :GetPlayingAnimationTracks(), where the table would not return any details about animations that the dummy is playing.
Example
Detector.Touched:Connect(function(hit) -- TOUCHED EVENT
if Busy == false then return end
if Registered == true then return end
if Blocking == true then return end
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local Detector = hit.Parent:FindFirstChild("Detector")
if Humanoid then
local Tracks = Humanoid:GetPlayingAnimationTracks()
for i, v in pairs(Tracks) do
print(v.Name) -- Prints "Animation"
print(v) -- Prints "Animation"
end
if Humanoid.Parent:GetAttribute("Blocking") == true then
Registered = true
local hitBlock = Humanoid.Parent
HitRegistered:FireServer(nil, nil, nil, hitBlock, Blockage, Sounds)
return end
Registered = true
HitRegistered:FireServer(Dmg, Humanoid, nil, nil, nil, Sounds)
elseif Detector then
if Detector.Parent.Parent.Parent:GetAttribute("Blocking") == true then return end
Registered = true
LoadAnims.Other.Parry:Play()
HitRegistered:FireServer(nil, nil, Detector, nil, nil, Sounds)
repeat Busy = true
wait()
until LoadAnims.Other.Parry.IsPlaying == false
Busy = false
end
end)
I think I’ve come to learn that it does not provide any details. It just allows you to run a :Stop() command on them, meaning that I cannot find a specific animation that someone may be playing whenever I try :GetPlayingAnimationTracks().
I came to ask if there were better methods to find out what animations a humanoid may be playing, or if I can find a way to identify a specific animation a humanoid is playing.
2 Likes
Using Humanoid:GetPlayingAnimationTracks()
will return AnimationTracks, not Animations. To get the Animation of an AnimationTrack, you can use AnimationTrack.Animation
.
I’m glad I saw this recently because I just tried it, and it was able to return something, but sadly it was the same thing:
https://gyazo.com/a0cc2e922cb49698c466b55273dec470
Here is what the name of the animation SHOULD be:
https://gyazo.com/87f3c3290be10904d58f128384ca937f
If you’d like to look through my code, because I’m not sure if I’m having any oversights here:
Detector.Touched:Connect(function(hit) -- TOUCHED EVENT
if Busy == false then return end
if Registered == true then return end
if Blocking == true then return end
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local Detector = hit.Parent:FindFirstChild("Detector")
if Humanoid then
local Tracks = Humanoid:GetPlayingAnimationTracks()
for i, v in pairs(Tracks) do
print(v.Animation.Name) -- Prints "Animation", should print "Hold"
end
if Humanoid.Parent:GetAttribute("Blocking") == true then
Registered = true
local hitBlock = Humanoid.Parent
HitRegistered:FireServer(nil, nil, nil, hitBlock, Blockage, Sounds)
return end
Registered = true
HitRegistered:FireServer(Dmg, Humanoid, nil, nil, nil, Sounds)
elseif Detector then
if Detector.Parent.Parent.Parent:GetAttribute("Blocking") == true then return end
Registered = true
LoadAnims.Other.Parry:Play()
HitRegistered:FireServer(nil, nil, Detector, nil, nil, Sounds)
repeat Busy = true
wait()
until LoadAnims.Other.Parry.IsPlaying == false
Busy = false
end
end)
Oh but interestingly enough it’s capable of printing the AnimationId?
https://gyazo.com/d6e767f64f9e27a18c26dd5684c6b63e
That’s weird, I just tested it out myself and it returned the correct name.
Let me try testing it between two test players. I’ve been using a dummy that’s handled on the server and that might be the issue.
I’m going to list this as a solution, because it did bring me a step forward.
My issue hasn’t necessarily been solved, but I think what I can do is use the AnimationId and compare it to the right Animation instances that are provided. This’ll just be a plan B sort of thing because I just think this function is buggy and I won’t bother trying to test it elsewhere.
Thank you!