The front face will be the one facing the wall so make sure that the part u want sticking to the wall is actually the front face. I can’t get much of your code as I don’t know any parts except the raycast part.
but the raycast part is the one positioning it, the functions you gave me made that grid for some reason, can you try adding the functions to the raycast to see if it will work as i probably did something wrong, there is nothing else causing the grid besides the lines i sent here
I sadly didn’t understand the math behind it so I can’t provide extra help…
can you provide a video of how yours works
I can’t provide one currently as I’m not using my laptop anymore. You can remind me later if you really wish to see it.
local RaycastParam = RaycastParams.new()
RaycastParam.IgnoreWater = true
RaycastParam.FilterType = Enum.RaycastFilterType.Exclude
RaycastParam.FilterDescendantsInstances = {player.Character, PreviewProp}
local MouseRay = mouse.UnitRay
local RayResult = workspace:Raycast(MouseRay.Origin, MouseRay.Direction.unit * maxPlaceDistance, RaycastParam)
if RayResult then
local ObjectPosition = RayResult.Position
local hitNormal = RayResult.Normal
local blockSize = PreviewProp.PrimaryPart.Size
local hitToCenterOffset = -hitNormal * (blockSize.y / 2)
local forwardVector = Vector3.new(0, -1, 0)
local rightVector = hitNormal:Cross(forwardVector).unit
local upVector = rightVector:Cross(hitNormal).unit
local ObjectRotation = CFrame.fromMatrix(Vector3.new(), rightVector, upVector, hitNormal)
local ObjectCFrame = CFrame.new(ObjectPosition + hitToCenterOffset) * ObjectRotation
PreviewProp:SetPrimaryPartCFrame(ObjectCFrame)
end
I’ve came up with this but it isnt really “perfect”
I still need help with this, anyone?