Running animation not playing

  1. What do you want to achieve? Keep it simple and clear!
    I want to achieve a running animation when the Left Shift button is held down while moving.

  2. What is the issue? Include screenshots / videos if possible!


  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

    i have looked on devforums for solutions

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local input = game:GetService("UserInputService")
local plrs = game:GetService("Players")
local localplr = plrs.LocalPlayer
local char = localplr.Character
local hum = script.Parent:FindFirstChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://18319166140"
local run = animator:LoadAnimation(anim)

	
input.InputBegan:Connect(function(input)
	if input.Keycode == Enum.KeyCode.LeftShift and char.PrimaryPart.Velocity.Magnitude > 0 then
		run:Play()
	end
end)

sorry if its a bit unorganized

1 Like

it was a typo :sob:
Keycode is supposed to be KeyCode

2 Likes

also, in this InputBegan I recommend doing this:

input.InputBegan:Connect(function(input,ischatting)
if not ischatting then
	if input.Keycode == Enum.KeyCode.LeftShift and char.PrimaryPart.Velocity.Magnitude > 0 then
		run:Play()
	end
end
end)

it prevents player from sprinting on accident when typing. Some games have more important keybinds and yet they don’t check this which can result in unintentional actions. You are just making a sprint system so you don’t really have to check as the player won’t be moving while typing.

1 Like

thank you i didnt even think of that :sweat_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.