How do i change the walk animations with a local script?

Wait. i can try one more thing. lemme see.

1 Like

local player = game.Players.LocalPlayer – defining player
local character = player.Character or player.CharacterAdded:Wait() --defining character
local humanoid = character:WaitForChild(“Humanoid”)–defining humanoid
humanoid.WalkSpeed = 20 --Changing Humanoid WalkSpeed Property

Okay. i just added an animation in the script. through the explorer.

it works but. theres 2 problems. i
1: it only works for RightShift
2 : The animation does not stop

1 Like

Ok wait it does work for leftshift too. but the animation wont stop when i let go of shift. [i have the toggle false]

I will update and fix these issues, including the invalid assetid (easiest fix)

There are already resources online to do this.

To make it work with a LocalScript instead of Server Script, I would make a local script inside of StarterCharacterScripts and go like:

wait(3)
script.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://YOURANIMATIONID"
script.Parent.Animate.run.RunAnim.AnimationId = "rbxassetid://YOURANIMATIONID"
2 Likes

Ok, I’ve updated the script, don’t forget to modify variables. I do not know if it will work though


i keep getting this. where it does not stop the anim

could you show me in a video

mp4 please

ok

reposting cuz getting annoying scrolling all the way up

--Top Variables (MUST CHANGE)
local animationId = 1

--Main Variables (do not change)
local humanoid = script.Parent:WaitForChild("Humanoid")
local sprinting = false
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local animation = Instance.new("Animation", script)
animation.AnimationId = "rbxassetid://"..tostring(animationId)
animation.Name = "Run"
local track = humanoid:WaitForChild("Animator"):LoadAnimation(animation)
track.Looped = true

--Config (optional changes)
local walkSpeed = 16
local runSpeed = 32
local toggle = true --false if you want to hold sprint
local createButton = false --whether to show button to sprint on mobile devices

----------------------------------------------------------------------------------
function sprint()
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) and UIS:IsKeyDown(Enum.KeyCode.RightShift) then return end
sprinting = not sprinting
if toggle then
if sprinting then
humanoid.WalkSpeed = runSpeed
track:Play()
else
humanoid.WalkSpeed = walkSpeed
end
else
humanoid.WalkSpeed = runSpeed
track:Play()
repeat task.wait(0.1) until UIS:IsKeyDown(Enum.KeyCode.LeftShift) == false and UIS:IsKeyDown(Enum.KeyCode.RightShift) == false
humanoid.WalkSpeed = walkSpeed
sprinting = false
end
end

CAS:BindAction("Sprint", sprint, createButton, Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift)
humanoid.WalkSpeed = walkSpeed

while track ~= nil and sprinting == false and track.IsPlaying do
task.wait()
track:Destroy()
track = humanoid:WaitForChild("Animator"):LoadAnimation(animation)
end

updated (maybe still wont stop anim)

@CaptainTeemukas

nope… is there a way to just swap out the walking animation?

what do you mean by that? just replace the anim?

like change the animation id of the walk anim. while its running.

so while it’s running, change walk anim?

while the animate local script is running’’

Animate script loads
Set walk animation to another ID

the thing is i tried that like a bajilion times

Animate.Walk.WalkAnim.AnimationID = Blah blah.
It still doesnt change

alr, you can delete the script i gave you if you don’t need it anymore

run the game, find your character and copy the animate script

then, exit testing and paste Animate into StarterCharacterScripts

inside the script, change the ids

i did that when i started making the game.i just want to change the animation id in the animate script when holding leftshift