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

How would I add a magnitude check to see if the player is running?

Asked by
FBS_8 25
4 years ago

Script:

wait(1)
local UIS = game:GetService("UserInputService")
local p = game:GetService("Players").LocalPlayer
local c  = p.Character or p.CharacterAdded:Wait()
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://4588222471"
local RunAnimation = c:WaitForChild("Humanoid"):LoadAnimation(anim)
UIS.InputBegan:Connect(function(i,a)
    if not a then
        if i.KeyCode == Enum.KeyCode.LeftShift then
            c:WaitForChild("Humanoid").WalkSpeed = 20
            RunAnimation:Play()
        end
    end
end)

UIS.InputEnded:Connect(function(i,a)
    if not a then
        if i.KeyCode == Enum.KeyCode.LeftShift then
            c:WaitForChild("Humanoid").WalkSpeed = 13
            RunAnimation:Stop()
        end
    end
end)

Answer this question