Hello, I have saw a post on the Devforum for a directional movement script and I ran into a bit of a problem.
The script works fine its just when I use two keys it starts to bug out and it doesnt detect that I’m going in a direction.
local PlayerServices = game:GetService("Players")
local RunService = game:GetService("RunService")
-----
local LocalChar = script.Parent
local LocalPlay = PlayerServices:GetPlayerFromCharacter(LocalChar)
local HumanoidRoot = LocalChar:WaitForChild("HumanoidRootPart")
local Humanoid = LocalChar:WaitForChild("Humanoid")
-----
local PrintingTru, Time = true, 0.24
local CurrentAnim = nil
-----
function ToWalkRelativeToHRP(Humanoid, Direction, RootCompare)
if Direction ~= nil then
local RootFacing = RootCompare.CFrame.LookVector
local RootRight = RootCompare.CFrame.RightVector
local DirectionRelativeToRootFront = RootFacing:Dot(Direction, RootFacing)
local DirectionRelativeToRootSides = RootRight:Dot(Direction, RootRight)
-----
local Output = nil
if DirectionRelativeToRootFront <= 1 and DirectionRelativeToRootFront >= 0.75 then
Output = "Forwards"
elseif DirectionRelativeToRootFront >= -1 and DirectionRelativeToRootFront <= -0.75 then
Output = "Backwards"
elseif DirectionRelativeToRootSides <= 1 and DirectionRelativeToRootSides >= 0.75 then
Output = "Right"
elseif DirectionRelativeToRootSides >= -1 and DirectionRelativeToRootSides <= -0.75 then
Output = "Left"
end
return Output
end
end
RunService.RenderStepped:Connect(function()
local ForceVector = ToWalkRelativeToHRP(Humanoid, Humanoid.MoveDirection, HumanoidRoot)
if PrintingTru then
print(ForceVector)
end
if ForceVector == "Forwards" then
elseif ForceVector == "Backwards" then
elseif ForceVector == "Right" then
elseif ForceVector == "Left" then
end
end)
Thank You.