K, I’ll send the tree code, I said that it seems that my game can hold trees until the fourth script is disabled, I also generate 4 65 million studs surface planets with terrain, after that I wait 85 seconds for the terrain to load, and then I generate trees on a noise like pattern, heres a sample of a tree generator:
for count = 1,1 do
local position
local diameter = 4500
local Seed = math.random(1000000,2000000)
for layer = 1,85,0.6 do
for steps = 1,360,1 do
position = CFrame.Angles(math.rad(steps),math.rad(-layer),math.rad(0))*CFrame.new(0,0,math.abs(diameter/2)) + workspace.Sphere1.PrimaryPart.Position
local noise = math.noise(steps/20,layer/20, Seed)
if noise <= 0 then
if math.random(1,3) == 1 then
local plant = game.ReplicatedStorage.PlantGenerator:Clone()
plant.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
plant.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
plant.Reference.Value = plant.Reference.Value - plant.Caster.Value.LookVector * 6000
plant.Caster.Value = plant.Caster.Value - plant.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(plant.Reference.Value.Position, plant.Caster.Value.LookVector * 10000)
if ray then
plant.Reference.Value = plant.Reference.Value + plant.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1P"):FireAllClients(plant.Reference.Value)
plant:Destroy()
else
plant:Destroy()
end
else
if math.random(1,3) == 1 then
local m = game.ReplicatedStorage.MineralGenerator:Clone()
m.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
m.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
m.Reference.Value = m.Reference.Value - m.Caster.Value.LookVector * 6000
m.Caster.Value = m.Caster.Value - m.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(m.Reference.Value.Position, m.Caster.Value.LookVector * 10000)
if ray then
m.Reference.Value = m.Reference.Value + m.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1M"):FireAllClients(m.Reference.Value)
m:Destroy()
else
m:Destroy()
end
end
end
else
if math.random(1,2) == 1 then
local tree = game.ReplicatedStorage.PlantGenerator:Clone()
tree.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
tree.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
tree.Reference.Value = tree.Reference.Value - tree.Caster.Value.LookVector * 6000
tree.Caster.Value = tree.Caster.Value - tree.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(tree.Reference.Value.Position, tree.Caster.Value.LookVector * 10000)
if ray then
tree.Reference.Value = tree.Reference.Value + tree.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1"):FireAllClients(tree.Reference.Value)
tree:Destroy()
else
tree:Destroy()
end
else
if math.random(1,2) == 1 then
local plant = game.ReplicatedStorage.PlantGenerator:Clone()
plant.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
plant.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
plant.Reference.Value = plant.Reference.Value - plant.Caster.Value.LookVector * 6000
plant.Caster.Value = plant.Caster.Value - plant.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(plant.Reference.Value.Position, plant.Caster.Value.LookVector * 10000)
if ray then
plant.Reference.Value = plant.Reference.Value + plant.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1P"):FireAllClients(plant.Reference.Value)
plant:Destroy()
else
plant:Destroy()
end
else
if math.random(1,4) == 1 then
local m = game.ReplicatedStorage.MineralGenerator:Clone()
m.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
m.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
m.Reference.Value = m.Reference.Value - m.Caster.Value.LookVector * 6000
m.Caster.Value = m.Caster.Value - m.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(m.Reference.Value.Position, m.Caster.Value.LookVector * 10000)
if ray then
m.Reference.Value = m.Reference.Value + m.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1M"):FireAllClients(m.Reference.Value)
m:Destroy()
else
m:Destroy()
end
end
end
end
end
end
steps = 0
wait()
end
end
wait()
for count = 1,1 do
local position
local diameter = 4500
local Seed = math.random(1000000,2000000)
for layer = 1,85,0.6 do
for steps = 1,360,1 do
position = CFrame.Angles(math.rad(-steps),math.rad(layer),math.rad(0))*CFrame.new(0,0,math.abs(-diameter/2)) + workspace.Sphere1.PrimaryPart.Position
local noise = math.noise(steps/20,layer/20, Seed)
if noise <= 0 then
if math.random(1,3) == 1 then
local plant = game.ReplicatedStorage.PlantGenerator:Clone()
plant.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
plant.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
plant.Reference.Value = plant.Reference.Value - plant.Caster.Value.LookVector * 6000
plant.Caster.Value = plant.Caster.Value - plant.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(plant.Reference.Value.Position, plant.Caster.Value.LookVector * 10000)
if ray then
plant.Reference.Value = plant.Reference.Value + plant.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1P"):FireAllClients(plant.Reference.Value)
plant:Destroy()
else
plant:Destroy()
end
else
if math.random(1,3) == 1 then
local m = game.ReplicatedStorage.MineralGenerator:Clone()
m.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
m.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
m.Reference.Value = m.Reference.Value - m.Caster.Value.LookVector * 6000
m.Caster.Value = m.Caster.Value - m.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(m.Reference.Value.Position, m.Caster.Value.LookVector * 10000)
if ray then
m.Reference.Value = m.Reference.Value + m.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1M"):FireAllClients(m.Reference.Value)
m:Destroy()
else
m:Destroy()
end
end
end
else
if math.random(1,2) == 1 then
local tree = game.ReplicatedStorage.PlantGenerator:Clone()
tree.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
tree.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
tree.Reference.Value = tree.Reference.Value - tree.Caster.Value.LookVector * 6000
tree.Caster.Value = tree.Caster.Value - tree.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(tree.Reference.Value.Position, tree.Caster.Value.LookVector * 10000)
if ray then
tree.Reference.Value = tree.Reference.Value + tree.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1"):FireAllClients(tree.Reference.Value)
tree:Destroy()
else
tree:Destroy()
end
else
if math.random(1,2) == 1 then
local plant = game.ReplicatedStorage.PlantGenerator:Clone()
plant.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
plant.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
plant.Reference.Value = plant.Reference.Value - plant.Caster.Value.LookVector * 6000
plant.Caster.Value = plant.Caster.Value - plant.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(plant.Reference.Value.Position, plant.Caster.Value.LookVector * 10000)
if ray then
plant.Reference.Value = plant.Reference.Value + plant.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1P"):FireAllClients(plant.Reference.Value)
plant:Destroy()
else
plant:Destroy()
end
else
if math.random(1,4) == 1 then
local m = game.ReplicatedStorage.MineralGenerator:Clone()
m.Reference.Value = position * CFrame.Angles(math.rad(90),0,0)
m.Caster.Value = position * CFrame.Angles(0,0,math.rad(-90))
m.Reference.Value = m.Reference.Value - m.Caster.Value.LookVector * 6000
m.Caster.Value = m.Caster.Value - m.Caster.Value.LookVector * 60000
local ray = workspace:Raycast(m.Reference.Value.Position, m.Caster.Value.LookVector * 10000)
if ray then
m.Reference.Value = m.Reference.Value + m.Caster.Value.LookVector * ray.Distance
game.ReplicatedStorage:WaitForChild("SendCF1M"):FireAllClients(m.Reference.Value)
m:Destroy()
else
m:Destroy()
end
end
end
end
end
end
steps = 0
wait()
end
end