local snapping = false
        local WallPos
        local MouseTarget = mouse.Target
        local target
        if MouseTarget then 
            target = MouseTarget.name
        end
        if target == "Foundation" then
            print("1")
            local ClosestDistance = math.huge
            local ClosestAttachment
            for _,attachment in pairs(mouse.Target:GetChildren()) do
                if attachment.Name == "WallSnapAttachment" then
                    snapping = true
                    local mousePos = mouse.Hit.p
                    local worldPos = attachment.WorldPosition
                    local distance = (mousePos - worldPos).Magnitude
                    if distance < ClosestDistance then
                        ClosestDistance = distance
                        ClosestAttachment = attachment

                    end
                    print("2")
                    local floor = mouse.Target
                    local wall = game.Workspace.Selection
                    wall.Transparency = 0.75
                    local wallCframe = floor.CFrame *CFrame.new(ClosestAttachment.Position)
                    wallCframe = wallCframe *CFrame.new(-wall.FloorAttachment.Position)
                    wallCframe = wallCframe *CFrame.Angles(math.rad(ClosestAttachment.Orientation.X), 0, math.rad(ClosestAttachment.Orientation.Z))
                    wall.CFrame = wallCframe
                    WallPos = wall.Position
                    print(("3"))
                    print(wallCframe)
                    print(snapping)
                end
            end
        else
            snapping = false
        end

his makes this happen https://streamable.com/gjpm77 how do i make it upright? this is in a while loop.

2 comments

1

100% something with lines 27-28, look what sets it's rotation so you can make it only go upright.

0

yes i think i fixed it