How to get the player direction

Do you mind telling how it didn’t work? Also how did you use the function?

I think i will use User input service, because it’s to much complex

You’ll have to be more specific, I don’t know what you’re looking for.

You want the move direction… relative to the velocity direction? That doesn’t make sense. Can you be more specific, or maybe give examples?

I want the velocity relarive to the body orientation, if the body are moving toward orientation = (0,0,0) then the value should be (0,0,16) beacause the z is the look vector

Many people have answered how to do this.

For example, @goldenstein64’s solution:

image

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local root = character:WaitForChild("HumanoidRootPart")

while wait() do
	local relativeVelocity = (root.CFrame - root.Position):Inverse() 
		* root.AssemblyLinearVelocity
	print(relativeVelocity)
end

Prints this while walking forward (holding W):

image

i.e. -16 in the Z direction (as expected)

and this while strafing right (holding D in first person):

image

i.e. +16 in the X direction.

@Ferghins’s solution would do the same thing.

Is that not what you’re looking for?

I know you say

But really, “forward” is in the negative Z direction, not positive Z.

1 Like

Yes! that’s exactly what I want, thank you and @goldenstein64 and everyone that helped me.

Feel free to mark @goldenstein64’s reply as the solution, I just copy pasted their code to prove it worked.