Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does Roblox studio start stuttering, then crashing if a too high value is entered?

Asked by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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:

  1. The terrain generator will not generate anything.

  2. Roblox studio starts stuttering the fps (60, 5, 1, 30, 5, 60, 3 etc.),

  3. 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.

Link to place to try it out

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 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

I put in numbers greater than 100 million and nothing of interest happened. I did notice that regardless of the seed, it was constantly regenerating the terrain (presumably because my character was animating and therefore technically "moving").

However, I did find this potentially wrong with your code: you don't delete Model when you're done deleting its children. Alternatively, you could re-use the Model (on line 19). This would create a very slow memory leak.

Also, it seems that the script you have provided is not the full story -- the script shown has no way of centring the blocks around the player - you don't even use the player parameter.

[Edit] My best guess for why it's lagging (based on the code you've given) is that there is some sort of implementation inefficiency in Roblox's code.

0
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. RubenKan 3615 — 7y
Ad

Answer this question