I am trying to detect when a player is playing a certain animation once you hit them with your sword. Except I have a big problem, and that it’s that the function :GetPlayingAnimationTracks() returns an empty Animation instance.
It should be returning an Animation instance named “Hold”, but it doesn’t? Here is the code:
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()
print(Tracks.Name) --prints nil?
if Humanoid.Parent:GetAttribute("Blocking") == true then
Registered = true
local hitBlock = Humanoid.Parent
HitRegistered:FireServer(nil, nil, nil, hitBlock, Blockage, Sounds)
return end
HitRegistered:FireServer(Dmg, Humanoid, nil, nil, nil, Sounds)
Registered = true
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)
repeat wait() until Hit.IsPlaying == false
Registered = false
Busy = false
LoadAnims.Hold:Play()
end)
Is there a rule with this function that I am missing?