Here's the script
local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Animate = Character:WaitForChild("Animate") local Animation = script.Parent:WaitForChild("Anim") local Anim = Animation.AnimationId local Original = Animate.walk.WalkAnim.AnimationId local Running = script.Parent:WaitForChild("Running") Running.Changed:Connect(function() print("Doing Stuff") if Humanoid.MoveDirection.Magnitude > 0 and Running.Value == true then Animate.walk.WalkAnim.AnimationId = Animation.AnimationId print("New Anim") else Animate.walk.WalkAnim.AnimationId = Original print("Old Anim") end end)
The problem is that the animations aren't loading correctly, if you want to play the sprint animation, You can't do it while walking, You have to press shift before you start walking. If you want to stop the animation, you have to stop walking.
I've tried multiple scripts to do this.. But the problem isalways the same, The animations have trouble playing.
You can change the Run animation of the character and the Walk animation if you want by going into the characters through a script and changing its animation settings.
local plr = game.Players.LocalPlayer local char = plr.Character local Anims = char.Animate local RunAnim = Anims.run.RunAnim RunAnim.AnimationId = "http://www.roblox.com/asset/?id=YOURID"
if you want to change it permanently you can add this script to StarterCharacterScripts and change the animation so anytime that the player runs its animation should be changed already and you wont have to do it everytime they press shift, and roblox automatically decides when to play the run anim for you.
I solved it! All I had to do was mae it so that the animation is loaded, played and immediatelly stopped, and let the animate script do the rest.
local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Animate = Character:WaitForChild("Animate") local Animation = script.Parent.Anim local Anim = Animation.AnimationId local OriginalAnim = Animate.walk.WalkAnim local Original = Animate.walk.WalkAnim.AnimationId local Running = script.Parent:WaitForChild("Running") Running.Changed:Connect(function() print("Doing Stuff") if Humanoid.MoveDirection.Magnitude > 0 and Running.Value == true then Animate.walk.WalkAnim.AnimationId = Animation.AnimationId local Test2 = Humanoid:LoadAnimation(Animation) print("New Anim") if Humanoid.MoveDirection.Magnitude > 0 then Test2:Play() Test2:Destroy() end else Animate.walk.WalkAnim.AnimationId = Original local Test = Humanoid:LoadAnimation(OriginalAnim) print("Old Anim") if Humanoid.MoveDirection.Magnitude > 0 then Test:Play() Test:Destroy() end end end)
Thanks to everyone who tried helping, even though You did not solve it, I really appreciate it!