I did this but the transition is not so smooth. Is there any way to make a simpler and better script like this? Please help, thank you! <3
01 | local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim) |
02 | local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause) |
03 |
04 |
05 | script.Parent.Equipped:Connect( function (mouse) |
06 | mouse.Button 1 Down:Connect( function () |
07 | anim:Play() |
08 | wait(anim.Length) |
09 | anim:Stop() |
10 | animPause:Play() |
11 | end ) |
12 | end ) |
I think you would need to make a continuing animation after that. You also need to destroy the playing animation when stopping. Code:
01 | local anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Anim) |
02 | local animPause = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.AnimPause) |
03 | local animResumeAnim = Instance.new( "Animation" ) |
04 | animResumeAnim.Parent = script |
05 | animResumeAnim.Name = "AnimResume" |
06 | local animResume = game.Players.LocalPlayer.Humanoid:LoadAnimation(animResumeAnim) |
07 |
08 | script.Parent.Equipped:Connect( function (mouse) |
09 | mouse.Button 1 Down:Connect( function () |
10 | anim:Play() |
11 | wait(anim.Length) |
12 | anim:Stop() |
13 | anim:Destroy() |
14 | animPause:Play() |
15 | end ) |
16 | mouse.Button 1 Up:Connect( function () |
17 | animResume:Play() |
18 | end ) |
19 | end ) |
If this works, please accept. Otherwise, comment and I will edit my answer.