Heya!!!
Currently im developing a game where each player gets the task to build a limb for a giant monster.
In the game the player gets a lot of freedom to customize their limb however they want. Theres just 1 problem… The method i use to retrieve the “Surface normal” of a part to position surface guis on doesnt work that well on cylinders/spheres.
Yes i could technically use the “Mouse.TargetSurface” to solve this issue but that also has a problem. Theres objects in the workspace that needs to be ignored. I cant just set “Mouse.TargetFilter” right now because that would break most of the game.
As you can see from these videos. The method i currently use works perfectly on cubes but on others well… not that well.
When hovering over a cube it prints out the normals numbers as ints.

But on others such as a sphere/cylinder it prints them as floats

Cube:
Cylinder/Sphere
Any help would be realy appreciated!! because as you can guess. Customization is the key component in the game so if i cant get this fixed then the game is basically dead.
Code i currently use to retreieve the surface normal of a part.
function Funcs:GetMouseTarget()
local Params = RaycastParams.new()
local Building = workspace.Assets.Building
local Mouse = game.Players.LocalPlayer:GetMouse()
local UnitRay = Mouse.UnitRay
local Faces = {
[Vector3.new(0,1,0)] = Enum.NormalId.Top,
[Vector3.new(0,-1,0)] = Enum.NormalId.Bottom,
[Vector3.new(0,0,-1)] = Enum.NormalId.Front,
[Vector3.new(0,0,1)] = Enum.NormalId.Back,
[Vector3.new(-1,0,0)] = Enum.NormalId.Left,
[Vector3.new(1,0,0)] = Enum.NormalId.Right,
}
Params.FilterDescendantsInstances = {game.Players.LocalPlayer.Character,Building.Radius,Building.Objects.PrimaryPart,Building.Parent.Debris}
Params.FilterType = Enum.RaycastFilterType.Exclude
local A = workspace:Raycast(UnitRay.Origin,UnitRay.Direction*1000,Params)
local Face = Faces[A.Normal] or Enum.NormalId.Front -- Returns "Front" as default to make sure it doesnt return nil.
return A.Instance,A.Position,Face
end