This item is not replicated across Roblox’s server/client boundary.
This property can only be read from. Attempting to write to it will cause an error.
MoveDirection is a read-only property that describes the direction a humanoid is walking in, as a unit vector along the X/Z axis. The direction is described in world space.
Walking Camera Bobble Effect
This LocalScript makes the camera bobble as the player’s character walks around, utilizing both the Humanoid’s CameraOffset and MoveDirection.
It should be parented inside of the StarterCharacterScripts so that it is distributed into a player’s character as expected.
local RunService = game:GetService("RunService") local playerModel = script.Parent local humanoid = playerModel:WaitForChild("Humanoid") local function updateBobbleEffect() local now = tick() if humanoid.MoveDirection.Magnitude > 0 then -- Are we walking? local velocity = humanoid.RootPart.Velocity local bobble_X = math.cos(now * 9) / 5 local bobble_Y = math.abs(math.sin(now * 12)) / 5 local bobble = Vector3.new(bobble_X,bobble_Y,0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed) humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble,.25) else -- Scale down the CameraOffset so that it shifts back to its regular position. humanoid.CameraOffset = humanoid.CameraOffset * 0.75 end end -- Update the effect on every single frame. RunService.RenderStepped:Connect(updateBobbleEffect)