#Sprint animation still playing when holding shift and not moving

1 messages · Page 1 of 1 (latest)

twilit relic
#

heres the script

#

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)

humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
idleAnimTrack:Stop()
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
idleAnimTrack:Play()
walkAnimTrack:Stop()
end
end
end)

idleAnimTrack:Play()

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 28
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://117203390936264'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
if walkAnimTrack.IsPlaying then
walkAnimTrack:Stop()
end
if idleAnimTrack.IsPlaying then
idleAnimTrack:Stop()
end
PlayAnim:Play()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 9.5
PlayAnim:Stop()
if humanoid.MoveDirection.Magnitude == 0 then
idleAnimTrack:Play()
else
walkAnimTrack:Play()
end
end
end)

worthy harbor
#

it seems like for the sprint you run the animation if left cntrl is pressed regardless of player input. Would this help? https://devforum.roblox.com/t/detect-if-a-player-is-moving-or-not/1859067

twilit relic
#

im a little confused of how it works since im still a little bit new to scripting heres what i did, and its still not working

#

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)

humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
idleAnimTrack:Stop()
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
idleAnimTrack:Play()
walkAnimTrack:Stop()
end
end
end)

idleAnimTrack:Play()

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

keen wigeonBOT
#

studio** You are now Level 1! **studio

twilit relic
#

UIS.InputBegan:connect(function(input)--When a player has pressed LeftShift it will play the animation and it will set the normal walking speed (16) to 35.
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 28
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://117203390936264'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
if walkAnimTrack.IsPlaying then
walkAnimTrack:Stop()
end
if idleAnimTrack.IsPlaying then
idleAnimTrack:Stop()
end
PlayAnim:Play()
end
game.Workspace.StarterPlayer.Humanoid.Running:Connect(function(speed)
if speed > 0 then
print("Player is running")
PlayAnim:Stop()
else
print("Player has stopped")
idleAnimTrack:Play()
end
end)
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = 9.5
PlayAnim:Stop()
if humanoid.MoveDirection.Magnitude == 0 then
idleAnimTrack:Play()
else
walkAnimTrack:Play()
end
end
end)

#

i had to split the messages because it was too long