How do you change the animation ID of an animation in a script

I am trying to make a walking animation when you walk but when you press CTRL the animation turns into a sprint. I attempted to change the animation ID to a sprinting animation but it isn’t working. Any suggestions or feedback?

Code:
local UIS = game:GetService(“UserInputService”)
local player = game.Players.LocalPlayer
local Character = player.Character
local humanoid = Character.Humanoid

UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then
return
elseif input.KeyCode == Enum.KeyCode.LeftControl and humanoid.WalkSpeed == 16 then
humanoid.WalkSpeed = 25
game.StarterPlayer.StarterCharacterScripts.Animate.walk.WalkAnim.AnimationId = “http://www.roblox.com/asset/?id=6950127912
elseif input.KeyCode == Enum.KeyCode.LeftControl and humanoid.WalkSpeed == 25 then
humanoid.WalkSpeed = 16
game.StarterPlayer.StarterCharacterScripts.Animate.walk.WalkAnim.AnimationId = “http://www.roblox.com/asset/?id=6949895562
end
end)

You should use :LoadAnimation() instead of changing the animation IDs.

I could try this, however, I have another question. How would you activate the ROBLOX “Run animation”. As of right now I am trying to change the walk animation ID but is there anyway I can just make the run animation start to play when i am walking at a certain speed.

Changing animation IDs probably isn’t in your best interest. If you take this approach, most of the time you’ll have to stop moving your character completely for the animation to update and play.

Playing the animation at a certain WalkSpeed would require more work on your end if I’m understanding you. I’d recommend loading the animation, then calling :Play() on InputBegan, and :Stop() on InputEnded.