Sprint animation script

Hello, i need help with a script i can´t make exactly what i want :grinning::

  1. Is a running script, the players runs when is pressed, the problem is that the animation is played with just pressing Left shift, so player running animatio is playing in same spot at least he press any letter from WASD

  2. So I try to make the animation only run if the player presses shift + any letter of “WASD”

Script:

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

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and Enum.KeyCode.W then
		Character.Humanoid.WalkSpeed = 35
		local Anim = Instance.new('Animation')
		Anim.AnimationId = 'rbxassetid://10584320932'
		PlayAnim = Character.Humanoid:LoadAnimation(Anim)
		PlayAnim:Play()
	end
end)

UIS.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Character.Humanoid.WalkSpeed = 16
		PlayAnim:Stop()
	end
end)

Please help me, and thanks for reading!

1 Like

I’m not too great of a scripter (I’ve had this issue before) but input.KeyCode can only be triggered with a single key if I’m correct? Maybe set up a tree of RemoteEvents that fire when the player presses a key? Boolean values? I don’t really know.

--uhhh ummmm i don't know
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift and script.W.Value == true or input.KeyCode == Enum.KeyCode.LeftShift and script.A.Value == true or input.KeyCode == Enum.KeyCode.LeftShift and script.S.Value == true or input.KeyCode == Enum.KeyCode.LeftShift and script.D.Value == true then
		Character.Humanoid.WalkSpeed = 35
		local Anim = Instance.new('Animation')
		Anim.AnimationId = 'rbxassetid://10584320932'
		PlayAnim = Character.Humanoid:LoadAnimation(Anim)
		PlayAnim:Play()
	end
end)

UIS.InputEnded:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Character.Humanoid.WalkSpeed = 16
		PlayAnim:Stop()
	end
end)

My apologies if I’m not helpful. :frowning:

1 Like

You can use:

UIS:IsKeyDown(Enum.KeyCode.W)

Adding on to this post, you should also use a, d and s as well as w.