I want to make a script that activates an animation and stops all the animations that a player has activated, that is, if for some reason the player has one or more animations running, stop them and execute the animation that I want, then stop said animation and come back and run the other animations that were stopped
To Stop Animations
local Anims = Humanoid.Animator:GetPlayingAnimationTracks() -- gets all Animations
for _,animation in Anims do -- Iterates through all Animations
animation:Stop() -- stops animations
end
8 Likes
This method worked in the past. I tried using :Stop on animationTracks just now, but it appeared to have no effect. For now, the only way to stop the animation tracks is to disable the animate script that Roblox uses to run the animations. Alternatively, if you want to stop individual animations, you can set their ID to '0
local function toggleAnimations(player, toggle)
local character = player.Character
if character then
local animate = character:FindFirstChild("Animate")
if animate then
animate.Disabled = not toggle -- Toggle the animate script
end
end
end
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
toggleAnimations(player,false)
end)
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.