Why is this raycasting not working?

Hello, I am trying to detect when a player is moving into a wall then I want to print("1"). Please note I’m fairly new to raycasting so I am confused on how to work it.
Here is my code;

local rayDirection = Vector3.new(0.2, 0, 0)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character, character.Head}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

runService.RenderStepped:Connect(function()
	if MOVEMENT_FUNCTIONS.CheckMovement() then
		
		local rayOrgin = character.Head.CFrame.LookVector
		
		local raycastResult = workspace:Raycast(rayOrgin, rayOrgin + rayDirection, raycastParams)
		
		local result2 = rayOrgin + rayDirection
		print(result2)
		
		if raycastResult then
			print("1")
		end
		
	end
end)

This is not enough having in mind Head’s size and the character will not always be looking at X axis.

Instead you should do something like this

local Head = character.Head
local raycastResult = workspace:Raycast(Head.Position, Head.CFrame.LookVector * 10, raycastParams)

Also, you’re not raycasting this, so it will give a Vector3, not an Instance result.

Thanks for your helpful response this seemed to fix it.

I do have one more question I also want to detect if they are moving side ways into the wall how could I check for this?

Humanoid haves a property called MoveDirection, you can check the direction they are moving to with X and Z axis.

How could I do this? Because if I do add a check e.g humanoid.MoveDirection.X > 0 then when I move left it will always not return true if I’m hitting the wall or not.