Grid system doesn't place on blocks on two specific places

  1. What do you want to achieve? A building system with a grid system.

  2. What is the issue? On the North and West of a block it doesn’t place, I assume due to the rounding equation. If its closer to one number on that side it will always round inside the block or something like that.

  3. What solutions have you tried so far? Chat GPT. Math.floor, Math.round, Math.Celi, Etc.

All help or advice is appreciated.

Video of Issue:


local MouseCFrame = Mouse.Hit
local MousePosition = MouseCFrame.p

local X = 4 * math.floor(MousePosition.X / 4 + 0.5)
local Y = 4 * math.floor(MousePosition.Y / 4 + 0.5)
local Z = 4 * math.floor(MousePosition.Z / 4 + 0.5)

Clone.Position =,Y,Z)

Game File:
Grid system.rbxl (55.9 KB)

1 Like

The script works perfectly fine. You just clicked on “Select” in the top bar of roblox studio (It’s obvious because you can see blue outline on the video).
Unselect it and you’ll have it.

1 Like

I selected it on video so I could show the block, more of a complex problem than that.

I ran into this issue also. You have to offset the placement of the block based on the mouse’s TargetSurface.


Can you give me an example, I don’t know how to do that.

if mouse.Target ~= nil then
	if mouse.TargetSurface == Enum.NormalId.Top then
		local X = mouse.Target.Position.X 
		local Y = mouse.Target.Position.Y + 4
		local Z = mouse.Target.Position.Z
	elseif mouse.TargetSurface == Enum.NormalId.Right then
1 Like

Thank you, it worked perfectly.

Incase anyone else had this issue, this is the code that fixed it.

local targetSurface = Mouse.TargetSurface
if targetSurface == Enum.NormalId.Bottom then
	Y = Y - 4
elseif targetSurface == Enum.NormalId.Front then
	Z = Z - 4
elseif targetSurface == Enum.NormalId.Left then
	X = X - 4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.