Reposting because some mod decided to delete my post for literally no reason.
code:
local context = game:GetService("ContextActionService")
local runbind = "RunBind"
local Player = game.Players.LocalPlayer
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild('Humanoid')
local RunAnimation = Instance.new('Animation')
RunAnimation.AnimationId = 'rbxassetid://9980814558'
RAnimation = Humanoid:LoadAnimation(RunAnimation)
Running = false
function Handler(BindName, InputState)
if InputState == Enum.UserInputState.Begin and BindName == runbind and Humanoid.WalkSpeed == 16 then
Running = true
Humanoid.WalkSpeed = 25
elseif InputState == Enum.UserInputState.End and BindName == runbind and Humanoid.WalkSpeed == 25
then
Running = false
if RAnimation.IsPlaying then
RAnimation:Stop()
end
Humanoid.WalkSpeed = 16
end
end
Humanoid.Running:connect(function(Speed)
if Humanoid.WalkSpeed == 25 and not RAnimation.IsPlaying then
RAnimation:Play()
else
if Humanoid.WalkSpeed == 16 and RAnimation.IsPlaying then
RAnimation:Stop()
end
end
end)
context:BindAction(runbind , Handler, true, Enum.KeyCode.LeftShift)
context:SetPosition(runbind, UDim2.new(.5, 0, .3, 0))
local button = context:GetButton(runbind)
button.Size = UDim2.new(.3, 0, .4, 0)
context:SetTitle(runbind, "Run")
when you open the pause menu (which i made) which disables the script the animations bug. You run when you don’t move and when you actually run it’s the running animation but it stops. Video:
Instead of Humanoid.Running, try using Humanoid.MoveDirection and check if it is greater than 1. If it is, then play the animation, or else stop the animation.
Sorry. What I meant was that if the Humanoid.MoveDirection had any value, you should play the animation. Because the default value of MoveDirection is Vector3.new(nan,nan,nan) just do if Humanoid.MoveDirection == Humanoid.MoveDirection then (I think). This is because nan ~= nan.
if Humanoid.MoveDirection == Humanoid.MoveDirection then doesn’t even play the animations.
if Humanoid.MoveDirection == Humanoid.MoveDirection then
if Humanoid.WalkSpeed == 25 and not RAnimation.IsPlaying then
RAnimation:Play()
else
if Humanoid.WalkSpeed == 16 and RAnimation.IsPlaying then
RAnimation:Stop()
My bad. I wasn’t sure if you could do that. Try: humanoid.MoveDirection.Magnitude > 0
I thought that since MoveDirection was nan by default that it would just work like that but apparently not.