How would i use raycast so that a parts position is continuously at the raycasted position?

more specifically, the part is supposed to be a foot, and I want it to be continuously planted at the raycasted position in every frame.

here is the code

rs.Heartbeat:Connect(function()
		
		
			
		if humanoid.MoveDirection.Magnitude > 0 then
			
			
			local raycastDirection = Vector3.new(0,-20,0)
			local raycastParams = RaycastParams.new()
			raycastParams.FilterType = Enum.RaycastFilterType.Exclude
			raycastParams.FilterDescendantsInstances = {RightFoot}	
				
			local raycastReulst = workspace:Raycast(RightFoot.Position, raycastDirection, raycastParams)
			
			if raycastReulst then
				RightFoot.Position = raycastReulst.Position -- here I want it the y value to be the raycasted y value and the x and z values are to be the humanoidrootparts x and y position
			end
        end
	
	
     
end)```

Wouldn’t you just do position= vector3.new(humanoidroot.position.x, raycasteesult.position.Y, humanoidroot.position.z)

i have tried this. it gives me the error message “attempt to index nil with ‘Position’”.

Do you have RightFoot defined or do you need to index vis to get it?

it is defined i just wanted to remove unnecessary parts that are not needed to see