Disable all Animations for a humanoid

Hello, I Have a setting in my game that disables animations for certain characters in the game,But i want to disable them temporarily, and even if a script plays an animation I want it to stop it.

local tracks = humanoid.Animator:GetPlayingAnimationTracks()
for i,track in next, tracks do
   track:Stop()
end

Is this the script you’ve been looking for?

But what if a script plays an animation after this code runs,would it play but i don’t want it to play after that even if the script plays it.

If you are running an animation by using Animator:LoadAnimation()
Then you easily can use Play() or Stop().

Example code:

local animId = 0000
animId = "rbxassetid://"..animId

local anim = Instance.new("Animation")
anim.AnimationId = animId

local humanoid = path.to.humanoid
local animator = humanoid.Animator

local animation = animator:LoadAnimation(anim)
animation:Play() -- Plays the animation.

wait(5) -- Waits 5 seconds

animation:Stop() -- Stops the animation

Ok,I’ll try to explain best:
There is a script inside the character that plays the animation when ever a button is pressed,
but in the main menu script i want to disable animations of that character and don’t want them to Play even when the script runs

Ohh!! I see, you can use the first method then.

local animation
local id = 000 -- The animation id that you want to stop.
for i,anim in next, humanoid.Animator:GetPlayingAnimationTracks() do
	if anim.AnimationId == "rbxassetid://"..id then
        animation = anim
		anim:Stop()
		break
	end
end

wait(5)
animation:Play() -- plays that animation after 5 seconds
animation = nil

Ok, So i want a code where it disables the character from playing an animation even if a script has a Play animation line