How to detect what Axis the ray has hit

Now to put it in simple terms, I want to detect what axis of a part a ray has hit, for example:

image

For instance, you can see the ray has hit -Y so basically the script should return -Y. Right now, I have no idea how to do that.

Thanks!

Use raycastResult.Normal which will give you a perpendicular vector to the plane the ray hit

Prints nothing, here’s my script(not full script):

elseif mouse.Target.Name == "Corner1" or "Corner2" or "Corner3" or "Corner4" then
	local rayorigin = mouse.Target
	local raydirection = Vector3.new(0,-2048,0)
	local params = RaycastParams.new()
	params.FilterDescendantsInstances(mouse.Target)
	params.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(rayorigin, raydirection, params)
	
		if raycastResult then
		
		local hitpart = raycastResult.Instance
		if hitpart.Parent == workspace and hitpart == t then
			 print(raycastResult.Normal)

If it prints nothing then
hitpart.Parent == workspace and hitpart == t
is false or there wasn’t a raycast result

Still not printing anything even though I took everything you said into consideration(not full script):

mouse.Button1Up:Connect(function()
	print("Relased plugin mouse.")
	if mouse.Target.ClassName == "Part" or "BasePart" or "UnionOperation" or "NegateOperation" and mouse.Target.Name ~= "Corner1" or mouse.Target.Name ~= "Corner2" or mouse.Target.Name ~= "Corner3" or mouse.Target.Name ~= "Corner4"then
		print("Target is on point.")
		t = mouse.Target
		local c1 = (t.CFrame * CFrame.new(t.Size.X/2, 0, t.Size.Z/2)).Position
		corners[1].Position = c1
		corners[1].Parent = workspace
		local c2 = (t.CFrame * CFrame.new(-t.Size.X/2, 0, t.Size.Z/2)).Position
		corners[2].Position = c2
		corners[2].Parent = workspace
		local c3 =  (t.CFrame * CFrame.new(-t.Size.X/2, 0, -t.Size.Z/2)).Position 
		corners[3].Position = c3
		corners[3].Parent = workspace
		local c4 = (t.CFrame * CFrame.new(t.Size.X/2, 0, -t.Size.Z/2)).Position 
		corners[4].Position = c4
		corners[4].Parent = workspace
	elseif mouse.Target.Name == "Corner1" or "Corner2" or "Corner3" or "Corner4" then
		local rayorigin = mouse.Target
		local raydirection = Vector3.new(0,0, -2048)
		local params = RaycastParams.new()
		params.FilterDescendantsInstances(mouse.Target)
		params.FilterType = Enum.RaycastFilterType.Blacklist
		local raycastResult = workspace:Raycast(rayorigin, raydirection, params)
		
			if raycastResult then
			
			local hitpart = raycastResult.Instance
			print(raycastResult.Normal)