I’ve made a script where when the player clicks a punching animations plays and damages anyone nearby with a humanoid. However I also have another script where when the player double taps W the players speed increases and plays a running animations.
When the player begins to run and punch at the same time both animations in sync with each other like this:
I wonder if anyone could help me with a way to stop the running animation from playing when ever the player clicks to punch. Keep in mind the scripts are different. The running animation is a local script and the punching animation is a local script which fires towards a script using a remote event.
Keep in mind the code: for i,v in pairs(Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop() end
Tends to be buggy and when it’s performed instead of ending the running animation every animation stops. Both animation priority’s are set to action
I believe that’s because of your priorities. If they’re both action, when another players, it’ll just override the other. If you set the running to Movement priority, the punch action will still override because it utilises the legs and arms, torso and others.
In my opinion, maybe trying to balance what animation controls what limb so you can sync it properly would be best. you can do this using the locking feature that like hides the limb from being used in the animation editor
Isn’t buggy, from what you describe it’s doing exactly what it’s supposed to do (get every animation track regardless of priority), if you want to stop tracks of certain priorities then consider doing the following.
for _, animation in ipairs(humanoid:GetPlayingAnimationTracks()) do
if animation.Priority == Enum.AnimationPriority.Action then --Only target action priority animations.
animation:Stop()
end
end
How would i implement this into a script that looks like this:
local green = script.Parent.Green
green.Touched:Connect(function(hit)
local player = game:GetService(“Players”):GetPlayerFromCharacter(hit.Parent)
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
if player then
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://10522159670"
local Track = Humanoid.Animator:LoadAnimation(Animation)
Track:Play()
Track.Looped = true
task.wait(10)
Track.Looped = false
end