Are you sure your animation is working? Have you tried debugging your code, adding in prints, etc? Anyways, just a sidenote humanoid:LoadAnimation is deprecated , so you should load animation on the animator instead. You can create an animator by using Instance.new(“Animator”) or reference it from the humanoid: local animator = humanoid:FindFirstChildOfClass("Animator")
. You also don’t need to load your animation within your UserInput events or create an animation there as well. I believe doing so means you’re creating a new animation and loading it each time the input is fired, which may cause an issue.
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6324141335"
if Humanoid then
local Animator = Humanoid:FindFirstChildOfClass("Animator") -- Get the Animator
if Animator then
PlayAnim = Animator:LoadAnimation(Animation) -- Load the animation
end
end
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
PlayAnim:Play()
Humanoid.WalkSpeed = 35
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
PlayAnim:Stop()
Humanoid.WalkSpeed = 16
end
end)