Camera sway + walk effect
Key RequiredUniversal

Camera sway + walk effect

Universal ScriptAbsolute_LampAbsolute_Lamp 216 views 695 executesUpdated Sep 7, 2026
Unrated
00
Lua Script•122 lines (5113 chars)
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local LocalPlayer = Players.LocalPlayer
local currentCamera = Workspace.CurrentCamera or Workspace:WaitForChild("CurrentCamera")

Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
    currentCamera = Workspace.CurrentCamera
end)

UserInputService.MouseIconEnabled = false

local function lerp(a, b, t)
    return a + (b - a) * t
end

for swayIndex = 1, 5 do
    task.spawn(function()
        local currentSway = 0

        RunService:BindToRenderStep("CameraSway_" .. swayIndex, Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
            local mouseDeltaX = UserInputService:GetMouseDelta().X
            local clampedDelta = math.clamp(mouseDeltaX, -7.5, 7.5)
            local lerpSpeed = 7 * deltaTime
            currentSway = currentSway + (clampedDelta - currentSway) * lerpSpeed
            
            if currentCamera then
                currentCamera.CFrame = currentCamera.CFrame * CFrame.Angles(0, 0, math.rad(currentSway))
            end
        end)
    end)
    task.wait(0.1)
end

for walkIndex = 1, 10 do
    task.spawn(function()
        local idleSwayX, idleSwayY = 0, 0
        local mouseSway, bobbingY, bobbingX = 0, 0, 0
        local cameraTilt = 0
        local stepTimer = 0
        local lookVectorOffset = Vector3.new()

        RunService.RenderStepped:Connect(function(deltaTime)
            local character = LocalPlayer.Character
            if not character then return end

            local humanoid = character:FindFirstChildOfClass("Humanoid")
            local rootPart = character:FindFirstChild("HumanoidRootPart") or (humanoid and humanoid.RootPart)

            if not humanoid or humanoid.Health <= 0 or not rootPart or not currentCamera then
                return
            end

            local deltaMultiplier = deltaTime * 30
            local velocity = rootPart.AssemblyLinearVelocity or rootPart.Velocity
            local moveSpeed = Vector3.new(velocity.X, 0, velocity.Z).Magnitude

            local baseWalkSpeed = math.max(humanoid.WalkSpeed, 1)
            local speedRatio = moveSpeed / baseWalkSpeed

            local dynamicBobSpeed = moveSpeed * 0.75
            local dynamicBobIntensity = speedRatio * 8

            if moveSpeed > 0.1 then
                stepTimer = stepTimer + (deltaTime * dynamicBobSpeed)
            else
                stepTimer = 0
            end

            if deltaMultiplier > 1.5 then
                idleSwayX, idleSwayY = 0, 0
            else
                local freqX = os.clock() * 0.5 * math.random(7.5, 10)
                idleSwayX = lerp(idleSwayX, math.cos(freqX) * (math.random(6, 10) / 100) * deltaMultiplier, 0.05 * deltaMultiplier)
                
                local freqY = os.clock() * 0.5 * math.random(5, 9)
                idleSwayY = lerp(idleSwayY, math.cos(freqY) * (math.random(1, 5) / 100) * deltaMultiplier, 0.05 * deltaMultiplier)
            end

            local baseCFrame = currentCamera.CFrame
            local mouseRotation = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(mouseSway))
            local bobbingRotation = CFrame.fromEulerAnglesXYZ(
                math.rad(bobbingY * deltaMultiplier), 
                math.rad(bobbingX * deltaMultiplier), 
                cameraTilt
            )
            local speedTilt = CFrame.Angles(0, 0, math.rad(bobbingY * deltaMultiplier * (math.min(moveSpeed, 35) / 5)))
            local idleRotation = CFrame.fromEulerAnglesXYZ(
                math.rad(idleSwayX), 
                math.rad(idleSwayY), 
                math.rad(idleSwayY * 10)
            )

            currentCamera.CFrame = baseCFrame * (mouseRotation * bobbingRotation * speedTilt * idleRotation)

            local relativeVelocity = -currentCamera.CFrame:VectorToObjectSpace(velocity / baseWalkSpeed).X * 0.04
            cameraTilt = math.clamp(lerp(cameraTilt, relativeVelocity, 0.1 * deltaMultiplier), -0.2, 0.2)

            local mouseDeltaX = UserInputService:GetMouseDelta().X
            mouseSway = lerp(mouseSway, math.clamp(mouseDeltaX, -2.5, 2.5), 0.25 * deltaMultiplier)

            if moveSpeed > 0.1 then
                local sineBob = math.sin(stepTimer) / 5
                local bobMultiplier = dynamicBobIntensity / 10
                bobbingY = lerp(bobbingY, sineBob * bobMultiplier, 0.25 * deltaMultiplier)

                local cosBob = math.cos(stepTimer * 0.5)
                bobbingX = lerp(bobbingX, cosBob * (dynamicBobSpeed / 120), 0.25 * deltaMultiplier)
            else
                bobbingY = lerp(bobbingY, 0, 0.1 * deltaMultiplier)
                bobbingX = lerp(bobbingX, 0, 0.1 * deltaMultiplier)
            end

            LocalPlayer.CameraMaxZoomDistance = 128
            LocalPlayer.CameraMinZoomDistance = 0.5
            lookVectorOffset = lerp(lookVectorOffset, currentCamera.CFrame.LookVector, 0.125 * deltaMultiplier)
        end)
    end)
    task.wait(0.1)
end

Features & Information

Camera sway wohoo🥹🥹🥹 i hope you guys like it😭😭

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts