I have a system where the mouse does a raycast to blocks, I need to make it to where you run a certain command it gets a NormalId, I have a system for this already, it just doesnt work with rotation, rotation offsets the NormalId
pretend this is a rotated part, and you need to place a particle emitter on it or something, and you are getting the side of it, and since its rotated, it will be on a completely different side.
I have pretty much tried as much as I could.
This is what I have so far.
function f.mouseBlockSide()
local target, pos = f.raycastMouse()
local offset = pos-target.Position
local lNum = 0
local largestAxis
for _, axis in pairs({'x', 'y', 'z'}) do
local value = offset[axis]
if math.abs(value) >= lNum then
lNum = math.abs(value)
largestAxis = axis
end
end
if largestAxis == 'x' then
return Vector3.new(offset.X, 0, 0).Unit
elseif largestAxis == 'y' then
return Vector3.new(0, offset.Y, 0).Unit
elseif largestAxis == 'z' then
return Vector3.new(0, 0, offset.Z).Unit
end
end