hello everyone, i am having a problem with my sprint script. Whenever i start sprinting, sometimes the camera shake is normal but a bit later it multiples and the shake is more intense. I checked the values of the speed and distances and its not because of this, is part of the camera shake lines, (which i took from another script). any help (sorry if this was confusing)
Script
--Services
local Service = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
--Player
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local humanoid = character:WaitForChild("Humanoid")
--Instances
Camera = workspace.CurrentCamera
--Tween
local timing = 0.5
local TweenInformation = TweenInfo.new(timing, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
--Camera
local Distance = 0
local Speed = 10
--Varbiles
local debounce = false
local runningfunction
local sprinting = false
--
script.Speedlol.Changed:Connect(function()
Distance = script.Speedlol.Value
end)
--
Service.InputBegan:connect(function(input, recieved)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
if player.Character then
if debounce == false then
debounce = true
sprinting = true
local humanoid1 = player.Character:FindFirstChild("Humanoid")
local Tween = TweenService:Create(script.Speedlol, TweenInformation, {Value = 3.75}):Play()
local Tween1 = TweenService:Create(humanoid1, TweenInformation, {WalkSpeed = 21}):Play()
local Tween2 = TweenService:Create(Camera, TweenInformation, {FieldOfView = 85}):Play()
runningfunction = RunService.RenderStepped:Connect(function()
Camera.CoordinateFrame = Camera.CoordinateFrame*CFrame.Angles(0,0,math.rad(Distance*math.sin(tick()*Speed))) --here is the problem
end)
wait(timing)
if Distance > 3.75 or script.Speedlol.Value > 3.75 or Speed > 10 then
Distance = 3.75
script.Speedlol.Value = 3.75
Speed = 10
end
debounce = false
end
end
end
end
end)
--
Service.InputEnded:connect(function(input, recieved)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.LeftShift then
if player.Character then
sprinting = false
local humanoid1 = player.Character:FindFirstChild("Humanoid")
local Tween = TweenService:Create(script.Speedlol, TweenInformation, {Value = 0}):Play()
local Tween1 = TweenService:Create(humanoid1, TweenInformation, {WalkSpeed = 16}):Play()
local Tween2 = TweenService:Create(Camera, TweenInformation, {FieldOfView = 75}):Play()
wait(timing)
if runningfunction then runningfunction:disconnect()runningfunction = nil end
end
end
end
end)
--