I'm attempting to create a grid that generates itself. Could someone point out to me why my stone is not only spawning in the wrong area, but not creating new layers on my Y axis?
The goal is to have bedrock spawn first, layout a 'sheet' for the base of the world and then have the rest of the terrain generate on top. The stone IS spawning, but its spawning inside of the bedrock layer and does not attempt to scale up on the Y axis.
Server Script
local Blocks = require(game:GetService("ServerScriptService"):WaitForChild("Modules"):WaitForChild("BlockStatistics"))
local worldwidth = 50 -- map size from border to border in blocks
local worldheight = 8 --[[map height from bedrock]] -127 +127 --This is the depth below sea level. Leave untouched for the vanilla experience.
function PrepareGrid()
local COrigin = Vector3.new(-(worldwidth/2),-worldheight, -(worldwidth/2))
for GridLayer = 0,worldheight,1 do
-- [Bedrock Generation]
if GridLayer <= 0 then
for GenXBedrock = 1,worldwidth,1 do
wait()
local Bedrock = Blocks.Bedrock():Clone()
Bedrock.Position = COrigin --laying bottom layer for Bedrock
Bedrock.Position = Bedrock.Position + Vector3.new((GenXBedrock*Bedrock.Size.X),0,0)
Bedrock.Parent = workspace
for GenZBedrock = 1,worldwidth,1 do
local BedrockZ = Bedrock:Clone()
BedrockZ.Position = Bedrock.Position + Vector3.new(0,0,(GenZBedrock*BedrockZ.Size.Z))
BedrockZ.Parent = workspace
end
end
end
-- [Stone Generation]
if GridLayer <= (worldheight-3) then
for GenYStone = 1,worldwidth,1 do
wait()
local Stone = Blocks.Stone():Clone()
Stone.Position = COrigin -- + Vector3.new(0,(GenYStone*Stone.Size.Y),0) -- Getting some weirdness here.
Stone.Parent = workspace
for GenZStone = 1,worldwidth,1 do
wait()
local StoneZ = Stone:Clone()
StoneZ.Position = Stone.Position + Vector3.new(0,0,(GenZStone*StoneZ.Size.Z))
StoneZ.Parent = workspace
for GenXStone = 1,worldwidth,1 do
local StoneX = Stone:Clone()
StoneX.Position = Stone.Position + Vector3.new((GenXStone*StoneX.Size.X),0,0)
StoneX.Parent = workspace
end
end
end
end
end
end
PrepareGrid()
Modular Script
local Blocks = {}
local BlockSize = Vector3.new(3,3,3) --Size of blocks in-game.
local BlockShape = "Block"
Blocks.Stone = function()
local ItemID = 1
local BlockType = game:GetService("ServerStorage"):WaitForChild("Blocks"):WaitForChild("Terrain"):WaitForChild("Stone")
return BlockType
end
Blocks.Bedrock = function()
local ItemID = 7
local BlockType = game:GetService("ServerStorage"):WaitForChild("Blocks"):WaitForChild("Terrain"):WaitForChild("Bedrock")
return BlockType
end
return Blocks
