I understand the use of the _G variable but it doesn't work because this animation is in a function. Are there any way I can solve it? Here is some code.
_G.KillAnim = plrs.Character:WaitForChild("Humanoid"):LoadAnimation(script.KillDragging) _G.SurvAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.Dragging2) _G.KillAnim:Play() _G.SurvAnim:Play()
The thing with that is, it wouldn't let me get the variable from a different script because it was inside of a scope, any ideas on how I could solve it?
You can use GetPlayingAnimationTracks on the Humanoid to stop the animation.
for i,v in pairs(humanoid:GetPlayingAnimationTracks()) do if v.Name == "Animation name here" then v:Stop() end end
Don't use global variables. It's really not a good idea when it comes to animations, unless you know 100% what you're doing. Use a RemoteEvent. You can find tons of tutorials for this on YouTube.
Upvote if this helped! :)