Hey guys, when my running animation is playing, and the player is jumping or falling, then the jump or fall animations will not play at all. It will just continue to run as I press Shift, and I don’t know why. I’ve seen multiple posts with the same issue, and in the replies, people are saying it’s due to a priority problem, such as this one and that I just have to set the animation to priorities to movements. However, these solutions do not work at all for me, and they are few years old, so I don’t know if something changed. But if anyone knows a solution for this, I’d be really grateful.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local players = game:GetService("Players")
local function onCharacterAdded(character)
local Hum = character:WaitForChild("Humanoid")
local HRP = character:WaitForChild("HumanoidRootPart")
local defaultWalkSpeed = 16
local maxWalkSpeed = 25
local defaultPlaybackSpeed = 1
local maxPlaybackSpeed = 1.20
Hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
local walkSpeed = Hum.WalkSpeed
local playbackSpeed = defaultPlaybackSpeed + (walkSpeed - defaultWalkSpeed) / (maxWalkSpeed - defaultWalkSpeed) * (maxPlaybackSpeed - defaultPlaybackSpeed)
playbackSpeed = math.clamp(playbackSpeed, defaultPlaybackSpeed, maxPlaybackSpeed)
HRP.Running.PlaybackSpeed = playbackSpeed
end)
end
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
onCharacterAdded(character)
end)
end)
local track
local isWalking = false
local function setCharacterSpeed(speed)
local character = Player.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid.WalkSpeed = speed
end
end
end
local function toggleRun(isRunning)
local player = game.Players.LocalPlayer
local character = player.Character
if not character then
return
end
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid:GetState() == Enum.HumanoidStateType.Seated then
return
end
local runSpeed = 25 -- running speed
if isRunning and isWalking then
humanoid.WalkSpeed = runSpeed
if not track then
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild('Animator')
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://14849258471"
Animation.Parent = script
track = animator:LoadAnimation(Animation)
track:Play()
onCharacterAdded(character)
end
else
humanoid.WalkSpeed = 16 -- default walk speed
if track then
track:Stop()
track:Destroy()
track = nil
end
end
end
local UserInputService = game:GetService("UserInputService")
local shiftHeld = false
local function checkShift(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
if gameProcessedEvent == false then
shiftHeld = input.UserInputState == Enum.UserInputState.Begin
toggleRun(shiftHeld)
else
shiftHeld = false
toggleRun(false)
end
end
end
local movementKeys = {} -- store the state of movement keys (W, A, S, D)
local function checkWalk(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.LeftShift then
shiftHeld = input.UserInputState == Enum.UserInputState.Begin
elseif (input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.D) then
movementKeys[input.KeyCode.Name] = input.UserInputState == Enum.UserInputState.Begin
end
local isAnyMovementKeyPressed = false
for _, keyState in pairs(movementKeys) do
if keyState then
isAnyMovementKeyPressed = true
break
end
end
if shiftHeld and isAnyMovementKeyPressed then
isWalking = true
toggleRun(true)
else
isWalking = false
toggleRun(false)
end
local character = Players.LocalPlayer.Character
if character then
onCharacterAdded(character)
end
end
UserInputService.InputBegan:Connect(checkShift)
UserInputService.InputEnded:Connect(checkShift)
UserInputService.InputBegan:Connect(checkWalk)
UserInputService.InputEnded:Connect(checkWalk)
I know my script is not very well organised
I ALSO want to mention that by “jumping” and “falling” animations, im talking about ROBLOX default jump and running animations, not customized ones, my game only contains an animation for running and nothing else.
PLEASE check the replies