Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Play Animation, But Go Back To Default Animation When Done Playing?

So after this script plays the animation, I want it to go back playing Roblox's character default animations, but it stays as the animation listed below. How do I make this happen? Thanks!

local animation = Instance.new('Animation')
animation.AnimationId = "http://www.roblox.com/Asset?ID=120735762"

function onEquip()
	script.Parent.Handle.UnsheathSound:Play()
end

function onActivate()
	script.Parent.Handle.SlashSound:Play()
	local player = game.Players.LocalPlayer.Character
	local animTrack = player.Humanoid:LoadAnimation(animation)
	animTrack:Play()
	script.Parent.Handle.Script.Disabled = false
end

script.Parent.Equipped:connect(onEquip)
script.Parent.Activated:connect(onActivate)

2 comments

0

When do you want the animation to end?

0

I want it to end when the animation finishes

1 answer

✓ Accepted answer

I assume the Animation has Loop set to true? You could reupload the animation with looping disabled. Another way is just doing animTrack:Stop() when you want. Maybe animTrack.Stopped:connect() can help, although I'm not sure if that fires for a looping animation.

1 comment

0

animTrack:Stop() works, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.