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.
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.
Using Humanoid:GetPlayingAnimationTracks() will return AnimationTracks, not Animations. To get the Animation of an AnimationTrack, you can use AnimationTrack.Animation.
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)
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.