Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make this script not run the running animation when im in place?

Asked by 4 years ago

I want to make so only when i press W,A,S,D and LeftShit to actualy play the animation.

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Human = game.Players.LocalPlayer.Character
local Humanoid = Character.Humanoid
local TrcanjeAnim = Instance.new("Animation")
 TrcanjeAnim.AnimationId = 'rbxassetid://4778662888'
 playTrcanjeAnim = Humanoid:LoadAnimation(TrcanjeAnim)

game:GetService("UserInputService").InputBegan:connect(function(input, gameprocesed)
    if input.KeyCode == Enum.KeyCode.LeftShift then
       for i = 1,16 do playTrcanjeAnim:Play()
            Human:WaitForChild("Humanoid").WalkSpeed = 30
        end
    end
end)

game:GetService("UserInputService").InputEnded:connect(function(input, gameprocesed)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        for i = 1,16 do playTrcanjeAnim:Stop()
            Human:WaitForChild("Humanoid").WalkSpeed = 16
        end
    end
end)

Answer this question