hello can someone help me with this script:
local runService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
function updateBobbleEffect()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- we are walking
local bobbleY = math.abs(math.sin(currentTime * 10)) * .35
local bobbleX = math.abs(math.sin(currentTime * 10)) * .05
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .2)
else -- we are not walking
humanoid.CameraOffset = Vector3.new(0, 0, -1)
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
it’s a shaking script, the problem is if the player walks the camera swing back I don’t know what the problem is