this is my code for it
i cant seem to figure out how to incorporate the "isMoving" variable which determines if any of the directional keys are being pressed
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local hum = char.Humanoid
local UIS = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local anim = script.sprint
local isMoving = false
local isSprinting = false
local animator = hum:FindFirstChildofClass("Animator")
local sprint = animator:LoadAnimation(anim)
UIS.InputBegan:Connect(function(key, isTyping)
if isTyping then return end
if key.KeyCode == Enum.KeyCode.LeftControl then
if isSprinting == false then
isSprinting = true
char.Humanoid.WalkSpeed = 32
for i=1,5 do
camera.FieldOfView = 80+(i*3)
wait()
end
sprint:Play()
elseif isSprinting == true then
isSprinting = false
char.Humanoid.WalkSpeed = 16
for i=1,5 do
camera.FieldOfView = 95-(i*3)
wait()
end
sprint:Stop()
end
end
end)
if UIS:IsKeyDown(Enum.KeyCode.W) then
isMoving = true
elseif UIS:IsKeyDown(Enum.KeyCode.A) then
isMoving = true
elseif UIS:IsKeyDown(Enum.KeyCode.S) then
isMoving = true
elseif UIS:IsKeyDown(Enum.KeyCode.D) then
isMoving = true
else
isMoving = false
end
