I'm trying to make 3 rays from the humanoid root part to the front of the player.

For some reason, the direction of the raycast is going somewhere completely unexpected. Sometimes it feels like it goes in random directions, and I'm not sure how to fix the issue. I even visualized the raycasts and it looks just like how I want it to be, but it's not correlating or associating with where the rays are actually going.


--Origins and Directions
local rayOrigin = hrp.CFrame.p
local rayOriginLeft = (hrp.CFrame * CFrame.new(2, 0, 0)).p
local rayOriginRight = (hrp.CFrame * CFrame.new(-2, 0, 0)).p
local rayDirection = hrp.CFrame.lookVector * 7
local rayDirectionLeft = (hrp.CFrame * CFrame.new(2, 0, 0)).lookVector * 7 
local rayDirectionRight = (hrp.CFrame * CFrame.new(-2, 0, 0)).lookVector * 7

--Casting Rays
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Character}	
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection + rayOrigin, raycastParams)
local raycastResultLeft = workspace:Raycast(rayOriginLeft, rayDirectionLeft + rayOriginLeft, raycastParams)
 local raycastResultRight = workspace:Raycast(rayOriginRight, rayDirectionRight + rayOriginRight, raycastParams)

--Visualizing the Rays
local p = Instance.new("Part", workspace)
p.Anchored = true
p.CanCollide = false
p.BrickColor = BrickColor.new("Really red")
p.Position = rayDirection + rayOrigin
print(raycastResult)
--Front
local distance = (rayOrigin - (rayDirection + rayOrigin)).Magnitude
local p = Instance.new("Part", workspace)
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.1, 0.1, distance)
p.CFrame = CFrame.lookAt(rayOrigin, rayDirection + rayOrigin)*CFrame.new(0, 0, -distance/2)
--Left
local distance = (rayOriginLeft - (rayDirectionLeft + rayOriginLeft)).Magnitude
local p = Instance.new("Part", workspace)
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.1, 0.1, distance)
p.CFrame = CFrame.lookAt(rayOriginLeft, rayDirectionLeft + rayOriginLeft)*CFrame.new(0, 0, -distance/2)
--Right
local distance = (rayOriginRight - (rayDirectionRight + rayOriginRight)).Magnitude
local p = Instance.new("Part", workspace)
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.1, 0.1, distance)
p.CFrame = CFrame.lookAt(rayOriginRight, rayDirectionRight + rayOriginRight)*CFrame.new(0, 0, -distance/2)]]--