My World Generation script isn't working, if world generation doesn't work, I don't know what I will do.

Code (Note: Very long)

local prefabs = game.ServerStorage.Prefabs
local cubes = 90
local width = 256
local length = 256
local height = 64
local x = -0.5
local y = 3
local z = 1.5
local rows = 1
local w = 0
local l = 0
local h = 0
local chance = 0
math.randomseed(tick())

--Void
function DrawBlock(block,xp,yp,zp,location,num)
  if num == "" then
	 local newBlock = Prefabs[block]:Clone()
	 newBlock.Parent = location
	 newblock.size = Vector3.new(5,5,5)
	 newBlock.CFrame = CFrame.new(xp,yp,zp)
  else
	local newBlock = prefabs[block]:Clone()
    newBlock.Parent = location
	newblock.size = Vector3.new(5,math.random(0,3),5)
	newBlock.CFrame = CFrame.new(xp,yp,zp)	
end
end

for i=1,width,1 do
  for i=-1,length,1 do
	for i=1,height,1 do
		wait()
		if w == width then
		w=0
	    rows=rows+1
	    x=x-3
	    z=1.5
	    print()
	    l=l+1
		elseif l==length then
			print(h)
			h=h+1
			w=0
			l=0
			z=1.5
			x=-0.5
			y=y-3
		elseif h == height then
			break
		else
			chance = math.random(0,3)
			if chance >0.15 and chance >0.7 then
				DrawBlock("Grass 2",x,y,z,workspace.Level,"")
			else
				DrawBlock("Stone 2",x,y,z,workspace.Level,"")
			end
			w=w+1
			z=z+(-3)
	      end
		end	
	  end
    end
    repeat wait() until h == height
    break
  else
	chance = math.random(0,3)
	if chance >2 then
				DrawBlock("Grass Block",x,y,z,workspace.Level,chance)
			else
				DrawBlock("Stone Block",x,y,z,workspace.Level,chance)
end

2 comments

0

Do put your code in a code block. Do this by highlighting the code by selecting it, then clicking the blue Lua icon.

0

isn't this the SpooksHD tutorial on world generation?, If it is then try rewatching the video to see any subtle details you missed out