How can I make a good grid system?

Okay, okay before this starts I know there has already been quite a few posts about grid.

Hey there devs! So, I’ve been struggling with finding a good grid system. I have a little bit of code but the ‘Y’ axis seems to go up by 0.25 or 0.5 (My guess.).

The model has a primary part has a primary part that covers all the other parts in the model. (It’s called Hitbox.)

And yeah here’s the script.

Code
local Mouse = game.Players.LocalPlayer:GetMouse()
local Grid = 4

local posX
local posY
local posZ

local function Snap()
	posX = math.floor(Mouse.Hit.X / Grid) * Grid
	posY = math.floor(Mouse.Hit.Y + (Grid / 2))
	posZ = math.floor(Mouse.Hit.Z / Grid) * Grid
end

Mouse.Move:Connect(function()
	Snap()

	game.Workspace.Block:PivotTo(CFrame.new(posX, posY, posZ) + Vector3.new((Grid / 2), 0, (Grid / 2)))
	Mouse.TargetFilter = game.Workspace.Block
end)
Pic

2 Likes