Need Help With A Rust Like Building System

So for the past month or so I’ve been trying to make a system that is like rust’s building system and so far I’ve had no luck at all. the placement system works but the snapping system just doesn’t want to work.

So right now I’ve seen these posts and tried their suggestions but it isn’t working…
see this is one of them : Placement System Using Attachments Creates Multiple Walls

so the problem with that one is that the walls are on a constant 45 degree that I cant fix

local RS = game:WaitForChild("ReplicatedStorage")
local ClickEvent = RS.PlacementSystem:WaitForChild("ClickToPlace")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ToolEquiped = false
local Tool = script.Parent
	ToolEquiped = true

function Main()
	while ToolEquiped == true do
		local WallPos
		local MouseTarget = mouse.Target
		local target
		if MouseTarget then 
			target =
		if target == "Foundation-Floor" then
			local ClosestDistance = math.huge
			local ClosestAttachment
			for _,attachment in pairs(mouse.Target:GetChildren()) do
				if attachment.Name == "WallSnapAttachment" then
					local mousePos = mouse.Hit.p
					local worldPos = attachment.WorldPosition
					local distance = (mousePos - worldPos).Magnitude
					if distance < ClosestDistance then
					ClosestDistance = distance
					ClosestAttachment = attachment
			local floor = mouse.Target
			local wall = game.Workspace.FakeWall
			wall.Transparency = 0.75
			local wallCframe = floor.CFrame *
			wallCframe = wallCframe *
			wallCframe = wallCframe *CFrame.Angles(0, math.rad(ClosestAttachment.Orientation.Y), 0)
			wall.CFrame = wallCframe
			WallPos = wall.Position
			local wall = game.Workspace.FakeWall
			wall.Transparency = 1
			ToolEquiped = false
			local wall = game.Workspace.FakeWall
			wall.Transparency = 1
		local enabled = true
			if not enabled then return end
			enabled = false
			enabled = true
-- thats the code i tried with another code in the serverscriptservice

if you can link me to some other toutorial or help me figure it out it would be much appreciated…

Hey sorry for taking a while to see this post, I hope you haven’t lost hope yet. So from what I can see you pretty much have the same code as me and I so far cannot see what could be causing this.

Here is my advice
  • What I found was best for debugging was to add in a print statement to show you what’s being processed. So when it comes to changing the orientation of the fake wall print the orientation you want it to be snapping to and see if it is correct or not. Doing this around the areas of you’re code that could be changing or affecting the wall can give you a better idea of what is going on.

  • Now I am not 100% sure as I am still learning to script and challenging myself but I would check out you’re attachments on the foundation block that the wall is snapped to as the orientation of those is what the wall is set to and if there is something wrong with those then that will be causing your problem.

  • I would recommend focusing on this area of code as well making sure you understand it and make sure there is nothing wrong with it since this is the only area that the fake wall changes orientation

Area of code

I hope this helped, if not sorry, If you’re really struggling then I am willing to maybe send you my code which is a bit more advanced than what you’re currently doing but not so much it won’t make sense just don’t use it for anything only to learn from. If you want to keep trying and my advice hasn’t worked please feel free to reply again and send me a video and possible you’re studio file and I can take a closer look at it compared to mine.

thank you for your help can you explain how your system works? that would be much appreciated since i cant think of a better way to do this system ATM.