try this script
local UserInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
local Camera = workspace.CurrentCamera
local localplayer = players.LocalPlayer
local character = localplayer.Character or localplayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local TweenInformation = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(Camera,TweenInformation,{FieldOfView=95})
local Tween2 = game:GetService("TweenService"):Create(Camera,TweenInformation,{FieldOfView=70})
local Key = Enum.KeyCode.LeftShift
local Running_Walkspeed = 20
local animation
local sprintTrack
local function Walking()
if sprintTrack then
sprintTrack:Stop()
animation = nil
sprintTrack = nil
humanoid.WalkSpeed = 7
Tween2:Play()
end
end
local function Runing()
animation = script:WaitForChild("Anim")
sprintTrack = humanoid:LoadAnimation(animation)
humanoid.WalkSpeed = Running_Walkspeed
sprintTrack:Play()
Tween:Play()
end
local function ShiftPressed()
return UserInputService:IsKeyDown(Key)
end
local function InputChanged(input,gPE)
if input.KeyCode == Key then
if ShiftPressed() then
if (humanoid.MoveDirection.Magnitude > 0) then
print("Runing")
Runing()
end
else
print("Walking")
Walking()
end
end
end
humanoid.Running:Connect(function(speed)
if speed == 0 then
Walking()
end
end)
UserInputService.InputBegan:Connect(InputChanged)
UserInputService.InputEnded:Connect(InputChanged)