Still have questions? Join our Discord server and get real time help.
0

# How do I make the block go into the correct place? [SOLVED]

A_thruZ 29
1 year ago
Edited by DeceptiveCaster 1 year ago

I'm building a Minecraft Spin-off for Roblox, and I have a working 4-block grid placement system, but most of the time the blocks are off by one snapping point. Although it depends on where on the block you tap, click, it sometimes, only sometimes goes to the incorrect block. Here's a snippet of code showing the build function. All of the building controls are binded to the function.

local function build()
local x = mouse.Hit.p.X
local y = mouse.Hit.p.Y
local z = mouse.Hit.p.Z

x = (round(x/4) * 4)
y = (round(y/4) * 4)
z = (round(z/4) * 4)

local position = Vector3.new(x + 2, y + 2, z + 2)

local part = Instance.new("Part", workspace)
part.Size = Vector3.new(4,4,4)
part.Position = position
part.Anchored = true
if material.Value == 1 then
part.Material = Enum.Material.WoodPlanks
part.BrickColor = BrickColor.new(38)
elseif material.Value == 2 then
part.Material = Enum.Material.Brick
part.BrickColor = BrickColor.Red()
elseif material.Value == 2 then
part.Material = Enum.Material.Cobblestone
part.BrickColor = BrickColor.Gray()
end
end


Help would be appreciated. Thank you!

0
Markdrg 15
1 year ago

Kinda easy Basically just

Just make all those 2s on line 10 1

So it would be

local position = Vector3.new(x + 1, y + 1, z + 1)

0
That wouldn't work, since each of my blocks are 4 x 4 x 4 studs A_thruZ 29 — 1y
0
Ah. Markdrg 15 — 1y