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

		if humanoid.MoveDirection.Magnitude > 0 then
			local raycastDirection =,-20,0)
			local raycastParams =
			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

Wouldn’t you just do position=, 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