#Sprint animation still playing when holding shift and not moving
1 messages · Page 1 of 1 (latest)
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)
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
I am looking to recreate my own version of an old zen/relaxation game from a long time ago. I want to make a script that when a person moves, it fires a command, and when the person stops moving it fires a different command. For demonstration purposes that command can be print(“moving”) and print(“not moving”). Right now the first step ...
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
** You are now Level 1! **
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