How could I detect when a player is turning?

Hi, I’m trying to make a system where if the player has a high enough walk speed, then when they turn left or right, a drifting sound and animation would play.

Problem is, I don’t know how I would detect when the player is turning in a way that would also work on mobile/console. You can just detect the move direction, yes, but to my knowledge, that would only work on PC since on mobile or console, due to having joysticks rather than keys, the movedirection value wouldn’t always be exact.

Please help!

1 Like

Well, you can try using the ControlModule inside the PlayerModule. That is inside PlayerScripts.

This is a LocalScript inside StarterPlayerScripts. Let me know if this solves your problem.

Edit: Note that it still triggers the direction even if the character is dead.

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

-- Instances
local Player = Players.LocalPlayer
local PlayerScripts = Player.PlayerScripts
local PlayerModule = PlayerScripts.PlayerModule
local ControlModule = PlayerModule.ControlModule

-- Variables
local controlModuleValue = require(ControlModule)

-- Connections
RunService.RenderStepped:Connect(function()

	-- Get the value from the method inside the ControlModule.
	local moveVector = controlModuleValue:GetMoveVector()

	if moveVector.X == -1 then
		-- This means that the player is turning left.

		print(Player.Name .. " is turning left.")

	elseif moveVector.X == 1 then
		-- This means that the player is turning right.

		print(Player.Name .. " is turning right.")

	end
end)

Thanks a lot, this worked great!