So today i was working on a terrain generator with math.noise, wich actualy works perfectly.
The only issues I currently have is when a too high "Seed" is entered:
The terrain generator will not generate anything.
Roblox studio starts stuttering the fps (60, 5, 1, 30, 5, 60, 3 etc.),
Eventualy Roblox studio completely freezes.
If anyone has any idea on why this could happen, please let me know.
(I've figured out it starts doing point 1,2 and 3 if the value is higher then the maximum 32 Bit Int value, but Negative value Seeds are possible too. (-3000 works just fine))
Here's the code, may anyone have any information on why this occurs, please let me know. Thank you.
local ChunkSize = 20
local running = false
script.Parent.Event.OnServerEvent:Connect(function(player,Seed)
if not Seed then return nil end
if running then return nil end
running = true
for _,v in pairs(game.Workspace.Model:GetChildren()) do
v:Destroy()
game["Run Service"].Heartbeat:wait()
end
for a=0,5 do
for b=0,5 do
local Model = Instance.new("Model",game.Workspace.Model)
game["Run Service"].Heartbeat:wait()
game["Run Service"].Heartbeat:wait()
game["Run Service"].Heartbeat:wait()
for BLAX=1,ChunkSize*2,1 do
for BLAY=1,ChunkSize*2,1 do
local X = BLAX /2
local Y = BLAY /2
local Z = Y
local Y = (1 + math.noise((a*ChunkSize+X)/30,(b*ChunkSize+Y)/30,Seed)/2)
local p =Instance.new("Part",Model)
p.Anchored = true
p.Size = Vector3.new(.5,.5,.5)
p.BrickColor = BrickColor.Green()
p.Material = Enum.Material.Grass
p.CFrame = CFrame.new(a*ChunkSize+X,Y*20,b*ChunkSize+Z)
if Y* 10 < 9.2 then
p.BrickColor = BrickColor.new("Br. yellowish green")
end
if Y*10 < 8.7 then
p.Material = Enum.Material.Sand
p.BrickColor = BrickColor.new("Cool yellow")
end
end
end
end
end
running = false
end)
EDIT: I know that I can easily solve this by checking if the number is higher then, lets say 1e45, but thats not what i'm going for. I wan't to find out why this happens.

1 comment
Those models do actualy get deleted, look closely (line 11-14). This answer isnt helping. Try 1e45, you'll lag out. The localscript that triggers it is an onClick function wich sends the seed, nothing more.