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

Animation stops when walking/jumping/idle?

Asked by 4 years ago

So I'm making a shooter game and I'm making a reload animation, however when you reload the animation suddenly stops if you try to walk or do any other action. if you stay still it sometimes works but if the second idle animation plays, the reload animation stops again. How do I prevent this from happening? I don't want any leg animations to be overridden by the reload animation, only the arms should be overridden by the reload animation.

(THE LOCAL SCRIPT THAT RUNS THE ANIMATION)

01anime = script.Parent.Animation
02debounce = false
03function play (dah)
04    if debounce == false then
05        local hum = game.Players.LocalPlayer.Character.Humanoid
06        local anim_feet = hum:LoadAnimation(script.Parent.Animation)
07        local current = anim_feet
08        local hum = game.Players.LocalPlayer.Character.Humanoid
09        local animation = anime
10        local animationLoad = hum:LoadAnimation(animation)
11        animationLoad:Play()
12        debounce = true
13        wait(1.5) --how long the animation lasts
14        debounce = false
15        current:Stop()
16        end
17    end
18script.Parent.Activated:Connect(play)

helpfull info: the local script is inside a tool. sometimes when you keep walking the reload will still play, however if you stop walking , the reload animation stops too.

1 answer

Log in to vote
0
Answered by 4 years ago

The answer is to increase the Priority. The priority allows you to play multiple animations at once without them interfering with each other. If you can, go into the Animation Editor and set the priority to Action from the menu where you save and load animations. (don't forget to export the animation again) If you don't want to go into the Animation Editor and change the priority, you can do it from the script side. (but this does not work all of the time)

01anime = script.Parent.Animation
02debounce = false
03function play (dah)
04    if debounce == false then
05        local hum = game.Players.LocalPlayer.Character.Humanoid
06        local anim_feet = hum:LoadAnimation(script.Parent.Animation)
07        local current = anim_feet
08        local hum = game.Players.LocalPlayer.Character.Humanoid
09        local animation = anime
10        local animationLoad = hum:LoadAnimation(animation)
11        --Set animation priority to action because action is the highest priority
12        animationLoad.Priority = Enum.AnimationPriority.Action
13        animationLoad:Play()
14        debounce = true
15        wait(1.5) --how long the animation lasts
16        debounce = false
17        current:Stop()
18        end
19    end
20script.Parent.Activated:Connect(play)

Hope I helped you resolve your problem.

0
I just noticed you define hum twice, there is no need for that since you are not changing the value. Also why do you define the same animation as both animationLoad and current? And why do you stop a not running animation (current)? vonotige 49 — 4y
Ad

Answer this question