I already found a script, but its problem that if you turn too fast, it will count as if you walking backwards
I’m using it to prevent running backwards, but as I said, if you turn too fast (to left or right), it will stop running too
local Character = script.Parent
local humanoid = Character:FindFirstChildOfClass("Humanoid")
local hrp = Character:FindFirstChild("HumanoidRootPart")
local PlayerFromChar = game:GetService("Players"):GetPlayerFromCharacter(Character)
game:GetService("RunService").Stepped:Connect(function()
if humanoid and hrp and PlayerFromChar then
local directive = hrp.CFrame:VectorToObjectSpace(humanoid.MoveDirection)
if directive.Z > 0 then
end
end
end)
I think the issue is that you’re comparing the humanoidRootPart’s cframe and not the camera’s when you calculate directive, because the hrp rotates (relatively)slowly behind the camera
Use the :Dot() product,
tl;dr VectorOne:Dot(VectorTwo) represents if vectors “looking” at the same direction
You could combine it with with HumanoidRootPart.CFrame.LookVector and Humanoid.MoveDirection to see where is character actually moving