im having this issue with this script when you spam shift it distorts your fov and your walkspeed and I don’t know how to fix this error.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = nil
local camera = game.Workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RS = game:GetService("RunService")
local IsRunning = script:WaitForChild("AnimStopped")
--
local Configuration = require(game.ReplicatedStorage.Modules:WaitForChild("Configuration"))
function IsWalking()
if humanoid.MoveDirection.Magnitude > 0 then
return true
else
return false
end
end
UIS.InputBegan:Connect(function(key, proccess)
if key.KeyCode == Configuration.RunKey then
if IsWalking() then
animation = humanoid:LoadAnimation(script.Animation)
IsRunning = true -- set this to true when key is pressed
humanoid.JumpPower = 0
humanoid.WalkSpeed = humanoid.WalkSpeed + 9
TweenService:Create(camera, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FieldOfView = camera.FieldOfView + 10}):Play()
end
end
end)
UIS.InputEnded:Connect(function(key, proccess)
if key.KeyCode == Configuration.RunKey then
IsRunning = false
humanoid.JumpPower = 50
humanoid.WalkSpeed = humanoid.WalkSpeed - 9
TweenService:Create(camera, TweenInfo.new(0.2 , Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {FieldOfView = camera.FieldOfView - 10}):Play()
end
end)
RS.Heartbeat:Connect(function()
if IsRunning and IsWalking() then
if animation and not animation.IsPlaying then
animation:Play(0.1,1,2)
end
else
if animation and animation.IsPlaying then
animation:Stop()
end
end
end)