Hello. Recently I have been creating a game where you build blocks with a color and a size value. The problem is, my block positioning system doesn’t account for uneven values. Vector3(1,1,1) works, but not Vector3(1,3,7) How could I incorporate uneven values too?
What I want to happen:
What happens:
The code that I think might be causing this:
local xDif = 0
local yDif = 0
local zDif = 0
local x = 0
local y = 0
local z = 0
if surface == Enum.NormalId.Top then
warn("top")
yDif = trackingPart.Size.Y
elseif surface == Enum.NormalId.Bottom then
warn("bottom")
yDif = -trackingPart.Size.Y
elseif surface == Enum.NormalId.Front then
warn("front")
zDif = -trackingPart.Size.X
elseif surface == Enum.NormalId.Back then
warn("back")
zDif = trackingPart.Size.X
elseif surface == Enum.NormalId.Right then
warn("right")
xDif = trackingPart.Size.Z
elseif surface == Enum.NormalId.Left then
warn("left")
xDif = -trackingPart.Size.Z
-- I have to make each one of these values change based on the parts size but I have no clue how to
end
local X = trackingPart.Size.X
local Y = trackingPart.Size.Y
local Z = trackingPart.Size.Z
local round = math.round(X + Y + Z / 3) / 6
if target.Name == "Block" then
x = math.round(target.Position.X) + xDif
y = math.round(target.Position.Y) + yDif
z = math.round(target.Position.Z) + zDif
else
x = math.round(Mouse.Hit.Position.X/round)*round
y = math.round(target.Position.Y/6) / 6 + yDif
z = math.round(Mouse.Hit.Position.Z/round)*round
end
Any help is appreciated.