I’m making a terrain system but it gets very laggy when it all loads in, i know i need to turn it into a union to enhance performance but i don’t exactly know how
Code:
local TileSize = math.random(1,100)
local Smoothness= math.random(2,20)
local Size = math.random(100,150)
local Frequency = math.random(10,60)
local Colours =
{
Color3.new(math.random(0,255),math.random(0,255),math.random(0,255)),
Color3.new(math.random(0,255),math.random(0,255),math.random(0,255))
}
for x = 1, Size do
for z = 1, Size do
local Height = (math.noise(x / Smoothness, z / Smoothness) + 2) * Frequency
p = Instance.new("Part")
p.Anchored = true
p.Parent = game.Workspace.Perlin
p.Size = Vector3.new(TileSize,Height,TileSize)
p.Color = Colours[math.random(1, #Colours)]
p.Position = Vector3.new(z * TileSize, Height, x * TileSize)
end
end
local Terrain = game.Workspace.Perlin:GetChildren()
p:UnionAsync(Terrain) -- issue
it’s also telling me this in the syntax:
Something went wrong. CSG returned error code -11. Please file a bug report, preferably with a file containing the problematic object(s).