I’ve been trying to figure out how’d I do it but I always seem to come to a dead end I’m wondering if mouse.hit needs to be used or ray casting
I do already have a placement system done I just need to get this rotation done.
Try this I dont remember the post I got it from but it uses ray casting to position the object on walls, but you have to use it on a model with a primary part that bounds the object completely
function placeAtMouse()
-- make sure the mouse is pointing at something
if mouse.Target then
-- cast our ray and get our normal, which is a unit vector
local unitRay = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y, 1) --origin, Vector3.new(0, -1, 0));
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 1000)
local hit, pos, normal = game:GetService("Workspace"):FindPartOnRay(ray, moveModel); print (normal)
moveModel:SetPrimaryPartCFrame(CFrame.new(pos,pos+normal*15) * CFrame.Angles(-math.rad(90),0,0))
end;
end;