RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Realistic camera bobbing script that activates if the player is moving"
-- local script local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local camera = game.Workspace.CurrentCamera local bobbingEnabled = false local bobbingMagnitude = 0.1 local bobbingSpeed = 2 local function updateBobbing() local elapsedTime = 0 local lastTick = tick() while bobbingEnabled do local deltaTime = tick() - lastTick elapsedTime = elapsedTime + deltaTime lastTick = tick() local bobAmount = math.sin(elapsedTime * bobbingSpeed) * bobbingMagnitude camera.CFrame = camera.CFrame * CFrame.new(0, bobAmount, 0) wait() end end local function checkMovement() while true do if humanoid.MoveDirection.Magnitude > 0 then if not bobbingEnabled then bobbingEnabled = true updateBobbing() end else bobbingEnabled = false end wait() end end checkMovement()