I am having a complete brain fart, I am trying to stop a animation in multiple models that exist and I get the error code that stop isn’t a valid member, am i missing something? I have tried looking at other posts along side the error I have but they don’t seem to do me any justice.
for i,v in pairs(MainFootballTeam:GetChildren()) do
v:WaitForChild("Animations").SnapStance.Animation:Stop()
v:WaitForChild("Animations").SnapAnim:Stop()
if v.Animations.SnapStance:FindFirstChild("Block") then
v.Animations.SnapStance.Block:Stop()
end
end
for i,v in pairs(AwayTeamPlayers:GetChildren()) do
v:WaitForChild("Animations").SnapStance.Animation:Stop()
v:WaitForChild("Animations").SnapAnim:Stop()
if v.Animations.SnapStance:FindFirstChild("Block") then
v.Animations.SnapStance.Block:Stop()
end
end
You create an AnimationTrack by calling LoadAnimation on either an Animator or Humanoid. Then you can store it somewhere (like as a value in an ObjectValue Instance).
-- Example
local animation = Object.Animation
local animationTrack = Player.Character.Humanoid.Animator:LoadAnimation(animation)
animationTrack:Play()
It would be preferred that you use v.Humanoid:GetPlayingAnimationTracks() since creating a new AnimationTrack for the same animation won’t affect the previously one made (what I’m saying is: If you want to stop the animation like this, it’ll create a new animation and stop that one instead of the old one).
local tracks = v.Humanoid.Animator:GetPlayingAnimationTracks()
for _, track in tracks do
if track.Animation == v.Animations.SnapStance.Animation then
track:Stop()
end
end