Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i make my building system wall stand upright?

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

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

2 comments

0

Is this a local script inside of a Tool?

0

yes it is

1 answer

Is the table rotated differently than the floor? Try making the table and the floor the same orientation. Either that or Only set the wall's cframe to the position instead of the position + rotation

1 comment

0

no luck with that how will you do it?

This discussion is preserved as it was. New answers, comments, and votes are closed.