How To Make A Ray Look To Same Space Area As An Attachment

  1. What do you want to achieve?
    Basicly I Need A Ray To Cast From An Attachment’s Position And Orientation So It Checks If There Will Be Something In A Way So It Doesn’t Overlap

  2. What is the issue?
    its just facing 1 way no matter what
    image

  3. What solutions have you tried so far?
    Making The Ray Use Actual Orientation Of The Attachment But Than It Doesn’t Work At All

	local RayOrigin1 = attachment2.WorldPosition
			local RayDirection1 = attachment1.WorldCFrame.LookVector
			print(RayDirection1)
			local Length = newpart.Size.Z
			--[[local viualiser = Instance.new("Part")
			viualiser.Parent = game.Workspace
			viualiser.Material = "Neon"
			viualiser.Anchored = true
			viualiser.Size = Vector3.new(0.25,0.25,Length)
			viualiser.Position = RayOrigin1+Vector3.new(0,0,Length/2) 
			viualiser.Orientation = RayDirection1--]]
				local resultZ = workspace:Raycast(RayOrigin1, RayDirection1 * Length)
			local Width = newpart.Size.X
				local resultX = workspace:Raycast(RayOrigin1+Vector3.new(0,0,Length/2), RayDirection1 * Width)
				

The WorldCFrame and WorldPosition are different than the properties you change. I’m pretty sure just removing the World part would fix it however you could also describe the position to be what you have right now and the direction to be

dir = CFrame.Angles(xOrientation,yOrientation,zOrientation) -- might be z for x
dir = dir.LookVector

i did some experimentation with it nothing changed the direction of the ray no matter what

local RayDirection1 = CFrame.Angles(0,attachment2.Orientation.Y,0)
			RayDirection1 = RayDirection1.LookVector 
			RayDirection1 = Vector3.new(RayDirection1.X,RayDirection1.Y,RayDirection1.Z)

btw its not attachment orientation its something else as i’ve changed tha value to be an actual number and shared the same result it was very low numbers when it printed the ray direction
image