How to detect a players movement direction suited to all platforms?

I am attempting to create a custom water system, with swimming and all. I have the moving set up right, but it only works for computer (cause of userinputservice inputs) but platforms like console and mobile literally can’t get detected. Is there a way to detect movement directions? And I don’t mean like, north ease west south, I mean if the player presses w, a mobile player drags the virtual stick up, a console player pushed their left joystick forward. I have seen other dev forum posts about this, but they don’t work the way I want them to, is there a way to efficiently do this?

You can use Humanoid.MoveDirection to detect where the Player’s Character is currently trying to move to

The Humanoid’s MoveDirection is relative to the workspace, not the players camera. (north ease south west) So one direction it would say I’m moving forward, and I turn 180 degrees and now I’m going backward supposedly, even though id still be pushing the w key, or moving the virtual or irl stick forward.

Give me one moment, I know theres a function for it under the PlayerModule.

Edit: Found it! This should work.
require(game.Players.LocalPlayer.PlayerScripts.PlayerModule.ControlModule):GetMoveVector()

Can you explain what this might be? does it revolve around the players velocity, or the literal input direction. Im manually moving the character by adding CFrame positions, so velocity wouldn’t work.

The players move vector is basically just what direction the player is moving in. If they’re moving forward it’ll be (0, 0, -1), backward (0, 0, 1) and so on and so fourth. Camera movement doesnt affect this.

What input a player is giving and the direction they are actually moving can be two different things.
They could be running forward while going north, south, east, or west. They could move forward and turn the camera, ending up moving in a different direction in world space.

Refine your question, be more specific.

MoveDirection
--duel direction
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local rs = game:GetService("RunService")

rs.RenderStepped:Connect(function()
	local dir = hum.MoveDirection
	if dir.Magnitude > 0 then
		local result = {}
		if dir.Z < 0 then table.insert(result, "Forward") end
		if dir.Z > 0 then table.insert(result, "Backward") end
		if dir.X < 0 then table.insert(result, "Right") end
		if dir.X > 0 then table.insert(result, "Left") end
		print(table.concat(result, " + "))
	end
end)
-----------
--from player
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rs = game:GetService("RunService")

local hum = char:WaitForChild("Humanoid")

rs.RenderStepped:Connect(function()
	local dir = hum.MoveDirection
	if dir.Magnitude > 0 then
		print(dir.X, dir.Y, dir.Z)
	end
end)
-----------
--from input
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local rs = game:GetService("RunService")

local control = require(plr.PlayerScripts.PlayerModule.ControlModule)

rs.RenderStepped:Connect(function()
   	local inputDir = control:GetMoveVector()
	if inputDir.Magnitude > 0 then
		print("Input", inputDir)
	end
end)

note:
directions

_, _, -1 → Forward
_, _, 1 → Backward
-1, _, _ → Right
1, _, _ → Left
0, 0, 0 → No movement

dual directions combinations

-1, _, -1 → Forward + Right
1, _, -1 → Forward + Left
-1, _, 1 → Backward + Right
1, _, 1 → Backward + Left

This works great (the one that uses :GetMoveVector(), but my goal was to detect on all devices. While it does this, it detects too precisely for it to work on a joystick. Is there a way to add a little. bit of wiggle room for what counts as forward and backward?

In the run test in players you can see playerscripts->player->module->controlmodule that is the roblox characters default character controller

there is a function called self:getmovevector() it returns the actual move vector of the player I don’t have a full understanding of it but you can still look at the script.

I found out that you can do

if InputDirection.Z < -0.5 and InputDirection.Z > -1 then

to detect forwards movement, and the positive of that for backwards. It works well for what im doing.

I was getting that too, even right it seems wrong.. That’s why I resorted to multiple ways and explanations, hoping you could put together testing that would work for you.