Hello DevForum. I’m trying to create a successful sprinting animation, however it seems like the sprinting animation is being overlapped by my idle or walking animation. (I provided my sprinting animation compared to the ingame one below)
I tried using :GetPlayingAnimationTracks() to stop the current animations already being played but it doesn’t seem to be working. Here is the script I used:
local AnimationTracks = Player.Character.Humanoid:GetPlayingAnimationTracks()
local Keybind = "LeftShift"
local StaminaCount = MaxStamina
UIS.InputBegan:Connect(function(key, processed)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode[Keybind] and StaminaCount > 0 then
StaminaUsed.Value = true
for i, track in pairs (AnimationTracks) do
track:Stop()
end
PlayAnim:Play()
end
end
end)
UIS.InputEnded:Connect(function(key, processed)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode[Keybind] then
StaminaUsed.Value = false
PlayAnim:Stop()
end
end
end)
This could be because to move while sprinting, you would press W (walking animation ) but I have tried merging the two KeyCodes already in this script, but it didn’t work out. I’m also seperating where the walking animation and running animation are if that somehow creates a problem.
I’d recommend having your idle animation set to action, then your walking animation to action2, then the throw animation to action3 (something along those lines)
This is because Roblox changed their animation system to instead combine (merge) animations, rather than have the last animation triggered overlap any other animation (with the same priority)
I just tried it out and it didn’t seem to solve the problem, however it might just be my fault though.
I set my walking animations to Action2, Idle animation to Action, Jump Animation to Action3, Throw animation to Action3, and Sprint Animation to Action4 but it ended up making the player only play the idle animation. (Note that I set the ToolNoneAnimation with the same idle animation so it might just mean all the animations stopped working lol)
I might have done something wrong when changing the priorities by script but here is how I did it: