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 + (RayResult.Normal * (PreviewProp.PrimaryPart.Size / 2))
local ObjectCFrame = CFrame.new(ObjectPosition.X, HeightingAmount + ObjectPosition.Y, ObjectPosition.Z)
local ObjectAngles = CFrame.Angles(0, math.rad(RotatingAmount), 0)
PreviewProp:SetPrimaryPartCFrame(ObjectCFrame * ObjectAngles)
end
We have a wall i already placed, and a preview model (a block) that im about to place.
When my mouse hovers over ANY side of the wall, the block gets positioned there properly.
But what i want to achieve is the same but i always want the X side of the block being the one attached to the wall/touching it.
if you dont get what i mean:
The block will always touch the wall on it’s X side, but always on a different side of the wall depending where my mouse is
Here is a image, where i place a wall (the transparent part is the body and the red part is the MainPart/PrimaryPart of the preview model), so on the left side you can see how it is right now, it just places randomly. But i want it to be like on the right side, that always the main part / that side of the model is faced towards the part your mouse is pointing at then while its there you can rotate it however you want (i already have the rotation)
im bad at explaining so sorry if its confusing