Many people to have a simple issue trying to figure out the direction relative to the player’s look direction. I have provided a sample of code which demonstrates the correct direction of a player’s movement direction, while locked in a certain angle such as shift lock. Hope this help with many!
local char = script.Parent
local hum = char:FindFirstChild("Humanoid")
local HumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
local runService = game:GetService("RunService")
runService.RenderStepped:Connect(function()
local dir = HumanoidRootPart.CFrame:VectorToObjectSpace(hum.MoveDirection)
print(dir)
if(dir.X<0 and dir.Z<0) then
if(dir.X>dir.Z) then
print("NORTH")
else
print("NORTH WEST")
end
end
if(dir.X>0 and dir.Z>0) then
if(dir.X<dir.Z) then
print("SOUTH")
else
print("SOUTH EAST")
end
end
if(dir.X>0 and dir.Z<0)then
local x = math.abs(dir.X)
local y = math.abs(dir.Z)
if(x>y) then
print("EAST")
else
print("NORTH EAST")
end
end
if(dir.X<0 and dir.Z>0)then
local x = math.abs(dir.X)
local y = math.abs(dir.Z)
if(x>y) then
print("WEST")
else
print("SOUTH WEST")
end
end
end)