So after trying to tweak a lot of things and change a lot of connections I’m still left with blocks just spawning almost inside other blocks
As you can tell I really don’t know how to put this all to together in a proper manner
Code:
local Seed = tick()
local Resolution = 4
local NumWorm = 1
local worms = {}
local spherecenters = {}
while NumWorm < 50 do
NumWorm = NumWorm + 1
local sX = math.noise(NumWorm/Resolution + 4,Seed)
local sY = math.noise(NumWorm/Resolution + sX + 4,Seed)
local sZ = math.noise(NumWorm/Resolution + sY + 4,Seed)
local WormCF = CFrame.new(sX * 500,sY * 500,sZ * 500)
local Dist = (math.noise(NumWorm/Resolution + WormCF.p.magnitude,Seed) + 0.5) * 500
for i = 1,Dist do
local X,Y,Z = math.noise(WormCF.X/Resolution + 4,Seed),math.noise(WormCF.Y/Resolution + 4,Seed),math.noise(WormCF.Z/Resolution + 4,Seed)
WormCF = WormCF*CFrame.Angles(X * 2,Y * 2,Z * 2)*CFrame.new(0,0,-Resolution)
table.insert(worms,WormCF.p)
end
end
for i = 2, #worms do
local prevPoint = worms[i - 1]
local currentPoint = worms[i]
local dir = (currentPoint - prevPoint).Unit
local dist = (currentPoint - prevPoint).Magnitude
for j = 0, dist,1 do
local spherecenter = prevPoint + dir * j
table.insert(spherecenters,spherecenter)
end
end
local function setblock(ID,pos)
local s,e = pcall(function()
if ID == 0 then
local block = Instance.new("Part")
block.Anchored = true
block.Size = Vector3.new(4,4,4)
block.Position = pos
block.Parent = workspace
elseif ID == 1 then
local block = Instance.new("Part")
block.Anchored = true
block.Size = Vector3.new(4,4,4)
block.Position = pos
block.Parent = workspace
elseif ID == 2 then
local region = Region3.new(pos,Vector3.new(4,4,4))
region = region:ExpandToGrid(4)
workspace:WaitForChild("Terrain"):FillRegion(region,4,Enum.Material.Water)
end
end)
if not s then
if e then
warn(e .. " (terrain)")
else
warn("Unkown or unexpected error (terrain?)")
end
end
wait()
end
function settype(blockTypeID, center, radius)
for x = center.X - radius, center.X + radius do
for y = center.Y - radius, center.Y + radius do
for z = center.Z - radius, center.Z + radius do
setblock(blockTypeID, Vector3.new(x, y, z))
end
end
end
end
for _, sphereCenter in pairs(spherecenters) do
settype(0,sphereCenter,1)
end