Ray going in a fixed direction when i move the part

i have no clue why it does not work, works fine when i have it past a point on the z axis but when it goes past that point it just goes to the z direction for no reason. The ray visualization shows the correct direction of the ray but the ray has a different idea where to go… This works by making rays form the attatment points inside the pressure plate . I can move it fine a couple of studs but past a point it breaks. And no i did not rotate it just moved it .

here is the script:

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)

local Plate = script.Parent.Plate

local plateDownTween = ts:Create(Plate, ti, {Position = Plate.Position - Vector3.new(0, Plate.Size.Y/2, 0)})
local plateUpTween = ts:Create(Plate, ti, {Position = Plate.Position})

local IsDown = false

local CanWork = true

function PlateDown()
	if IsDown == false then
		plateDownTween:Play()
		IsDown = true
		Plate.Color = Color3.new(0.513725, 1, 0.403922)
		--print("Down")
	end

	
end

function PlateUp()
	if IsDown == true then
		plateUpTween:Play()
		IsDown = false
		Plate.Color = Color3.new(0.768627, 0.156863, 0.109804)
		--print("Up")
	end

end



function CheckForTouch()
	local HasResult = false
	local Points = Plate:GetChildren()
	
	for i,v in pairs(Points) do
		if v:IsA("Attachment") then
			local rayOrigin = v.WorldCFrame.Position
			local rayDirection = Vector3.new(v.WorldCFrame.Position.X,v.WorldCFrame.Position.Y,v.WorldCFrame.Position.Z - 2)

			local raycastParams = RaycastParams.new()
			raycastParams.FilterDescendantsInstances = {script.Parent,workspace.GameLevels,workspace.SpawnArea,workspace.Checkpoints,workspace.EndArea}
			raycastParams.FilterType = Enum.RaycastFilterType.Exclude
			raycastParams.IgnoreWater = true

			local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)

			if raycastResult then
				HasResult = true
				--print(raycastResult.Instance.Name.." "..raycastResult.Instance.Parent.Name)
			else
				--print("NoResult")
			end
			
			
			
			local distance = (rayOrigin - rayDirection).Magnitude
			local p = Instance.new("Part")
			p.Anchored = true
			p.CanCollide = false
			p.Size = Vector3.new(0.1, 0.1, distance)
			p.CFrame = CFrame.lookAt(rayOrigin, rayDirection)*CFrame.new(0, 0, -distance/2)
			p.Parent = script.Parent--]]

			
		end

	end
	
	if HasResult == true then
		PlateDown()
	else
		PlateUp()
	end
end



while true do wait(0.7)
	if script.Parent.CanWork.Value == true then
		CheckForTouch()
	end

end