Building keeps no-clipping near the top of other buildings

  1. I want to make a building mode in my building system where you can place walls glued to each other.

  2. The mode works fine until it reaches near the top of other buildings, when it does it starts no-clipping inside of them. It only doesn’t do that when my camera is lower than the building’s top, so I’m guessing it has to do something about the camRay.

How it should look like:

How it looks like:


Do note that it only no-clips when it’s near the top and my camera is higher than the block, if my camera is lower, then it doesn’t no-clip.

  1. I tried looking through the devforum and tried changing my code a ton of times to fix that, but none of that seemed to work. If I missed a devforum page that went through this, please link it to me.

This is my code:

		while equipped and eMode do
			if (mouse.Hit.p - tool.Handle.Position).Magnitude <= 50 then
				sticky.BrickColor ="Bright green")	
				sticky.BrickColor ="Really red")
			local camRay = camera:ViewportPointToRay(mouse.X, mouse.Y)
			local param =
			param.FilterDescendantsInstances = {mouse.Target}
			param.FilterType = Enum.RaycastFilterType.Whitelist
			local res = workspace:Raycast(camRay.Origin,camRay.Direction*600,param)
			if res then
				sticky.CFrame =, mouse.Hit.p + res.Normal)
				sticky.CFrame = sticky.CFrame + (sticky.CFrame.LookVector * (sticky.Size.Z/2))
				sticky.Orientation =,sticky.Orientation.Y,rValue)
			else do
					sticky.Position = mouse.Hit.p + sticky.CFrame.LookVector * (sticky.Size.Z/2)

Any help is appreciated, thanks.

You could try raycasting below where you want to place it to check if there is anything, and place the walls at the hit position but with like 1 more in the Y axis.

I don’t want it to go to the floor tho, I want it to be glued to what the mouse is currently hovering over