PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Move

This function causes the Humanoid to walk in the given DataType/Vector3 direction.

By default, the direction given is in world terms. If the relativeToCamera parameter is true however the direction given is relative to the Workspace/CurrentCamera|CurrentCamera’s DataType/CFrame. As the negative Z direction is considered ‘forwards’ in Roblox, the following code would make the Humanoid walk in the direction of the Workspace/CurrentCamera.

humanoid:Move(Vector3.new(0, 0, -1), true)

When this function is called, the Humanoid will move until the function is called again. However, if the default [control scripts][1] are being used this function will be overwritten when called on Player Player/Character|Characters. This can be avoided by either not using the default [control scripts][1], or calling this function every frame using RunService/BindToRenderStep (see example).

This function can be called on the server, but this should only be done when the server has [network ownership][2] of the Humanoid|Humanoid’s assembly.

See also

  • To make aHumanoid walk to a point, use the Humanoid/MoveTo function
  • For Player|Players the Player/Move|Player:Move function exists that calls this function

[1] https://www.robloxdev.com/articles/Movement-and-camera-controls
[2] https://www.robloxdev.com/articles/Network-Ownership

Parameters

Name Type Default Description

The direction to walk in

false

True if the direction parameter should be taken as relative to the Workspace/CurrentCamera

Returns

Return Type Summary

No return


Code Samples


Moving a Humanoid Forwards

This code sample uses the Humanoid/Move function to make the Player|Player’s Player/Character|Character to walk in the direction of the Camera.

RunService/BindToRenderStep is required here as the default control scripts will overwrite the player’s movement every frame.

To run this sample, place it inside a LocalScript parented to StarterCharacterScripts|StarterPlayer.StarterCharacterScripts.

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer

RunService:BindToRenderStep("move",
    -- run after the character
    Enum.RenderPriority.Character.Value + 1,
    function()
   	 if localPlayer.Character then
   		 local humanoid = localPlayer.Character:FindFirstChild("Humanoid")
   		 if humanoid then
   			 humanoid:Move(Vector3.new(0, 0, -1), true)
   		 end
   	 end
    end
)