Want to stay connected to the Scripting Helpers community and get real-time help? Join the Scripting Helpers Discord Server!
Log in to vote

How can i reduce brick lag from a terrain gen script?

Asked by
NexeusX 137
1 year ago
Edited 1 year ago

I made my own terrain generation script after a couple hours of testing, and it generates 3x3 bricks randomly...my problem is that i want the map to be pretty big but the amount of bricks causes major lag is there a solution to fix the lag?

Here is the script, but there are StringValues in the script itself.

DataBase = {}
table.insert(DataBase, script.Material_1.Value)
table.insert(DataBase, script.Material_2.Value)
table.insert(DataBase, script.Material_3.Value)
table.insert(DataBase, script.Material_4.Value)
table.insert(DataBase, script.Material_5.Value)
table.insert(DataBase, script.Material_6.Value)
NumBers1 = script.Parent.Name * 6
total = 60 - NumBers1

for i = -3,3, .1 do
  for j = -3,3, .1 do
    y = math.log (1) * (i^1 + j^1) - 1
    choose = (DataBase[math.random(1,6)])
    nex = game.Lighting.Terrain:FindFirstChild(choose)
    p = nex:clone()
    p.CFrame = CFrame.new(Vector3.new(60*i, total*y, 60*j))
    p.Anchored = true
    p.BottomSurface = "Smooth"
    p.TopSurface = "Smooth"
    p.Parent = game.Workspace

Can you post the script. kingdom5 3674 — 1y
i posted it NexeusX 137 — 1y

Answer this question