Made a simple shift to sprint, wanting to make the players FOV change when they engage and disengage sprinting. Here's my code
--player local player = game:GetService("Players").LocalPlayer local char = player.Character or player.CharacterAdded:wait() local human = char:WaitForChild("Humanoid") --camera local cam = game.Workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable human:GetPropertyChangedSignal("WalkSpeed"):connect(function() if human.WalkSpeed == 24 and cam.FieldOfView < 90 then while cam.FieldOfView < 90 do cam.FieldOfView = cam.FieldOfView + 2 wait() end end if human.WalkSpeed == 16 and cam.FieldOfView > 70 then while cam.FieldOfView > 70 do cam.FieldOfView = cam.FieldOfView - 2 end end end)
it produces this result: https://gyazo.com/3cbaf487456cc44c2e2044d507fa7cc7
Any ideas of how to stop it not being connected to the player? Also, the script doesn't go through the second while loop, when the FOV is greater than 70, help would be appreciated.
line 7 in the code has a problem
--player local player = game:GetService("Players").LocalPlayer local char = player.Character or player.CharacterAdded:wait() local human = char:WaitForChild("Humanoid") --camera local cam = game.Workspace.CurrentCamera --cam.CameraType = Enum.CameraType.Scriptable human:GetPropertyChangedSignal("WalkSpeed"):connect(function() if human.WalkSpeed == 24 and cam.FieldOfView < 90 then while cam.FieldOfView < 90 do cam.FieldOfView = cam.FieldOfView + 2 wait() end end if human.WalkSpeed == 16 and cam.FieldOfView > 70 then while cam.FieldOfView > 70 do cam.FieldOfView = cam.FieldOfView - 2 end end end)
this code should work