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

How Would I Determine The Y-Axis In A Placement System?

Hello, I'm currently trying to make my own Stamper Tool, a problem I'm mainly having throughout making the models and parts snap to a grid is the Y Axis. The models and parts are in the ground. Here's the function I'm currently using to have the models and parts snap onto a grid.

local grid = 4
local function RoundToNearest(ToRound, Increment)
	return floor(ToRound / Increment + 0.5) * Increment
end

local function snap()
	local positon = mouse.Hit.p
	return CFrame.new(RoundToNearest(positon.X, grid), RoundToNearest(positon.Y, grid), RoundToNearest(positon.Z, grid))
end

My question is, how would I determine the Y-Axis of the model/part while also making sure you could build the models/parts upon each other.

1 answer

✓ Accepted answer

Seems like the issue in the image is that the ground isn't at the same level as the grid, if you lower the ground it should work fine - You could also do RoundToNearest(position.Y, grid) + 2 or however deep it is in the ground there.

1 comment

0

Thanks! Simply increasing the Y value by two worked, and everything else works.

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