RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Realistic camera bobbing script that activates if the player is moving"
-- local script local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local camera = workspace.CurrentCamera local bobbing = false local bobAmount = 0.1 local bobSpeed = 5 local function bobCamera() local originalPos = camera.CFrame local start = tick() while bobbing do local t = tick() - start local yPos = math.sin(t * bobSpeed) * bobAmount camera.CFrame = originalPos * CFrame.new(0, yPos, 0) wait() end camera.CFrame = originalPos end while true do if humanoid.MoveDirection.Magnitude > 0 and not bobbing then bobbing = true bobCamera() elseif humanoid.MoveDirection.Magnitude == 0 then bobbing = false end wait() end