Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I delete an animation after it's played?

Asked by 4 years ago

I am trying to delete the animation at the end when it gets stopped, but I am having trouble with that, I've tried Instance:Remove with a few variations but each has fed me an error.

01local player = game.Players.LocalPlayer
02local Character = player.Character or player.CharacterAdded:Wait()
03local Humanoid = Character:WaitForChild("Humanoid")
04local Script = Character:WaitForChild("Animate")
05 
06local debounce = false
07    script.Parent.MouseButton1Click:Connect(function(clicked)
08        if not debounce then
09            debounce = true
10            player.Character.Animate.Disabled = true
11            local Animation = Instance.new("Animation")
12            Animation.AnimationId = "rbxassetid://5035220879"
13            Animation.Parent = player.Character
14            Animate = Humanoid:LoadAnimation(Animation)
15            Animate:Play()
View all 21 lines...

1 answer

Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
4 years ago

I'm sure you can just do

1Animate:Destroy()

whenever you need to, to get rid of the Animation when it's over. Not sure why :Stop() isn't enough for that but whatever you gotta do, you gotta do.

Ad

Answer this question