Generated maps make caves and its breaking my game

Ah, right, I see that now. There might still be a problem here though:

and

The problem is that the reference implementation of Improved Perlin noise, which I believe is what math.noise uses, is periodic in every direction with a period of 256. So, even if you have 100k possible seed values, because they are integers, you’ll only get 256 different maps. Try changing your calls to be like this:

math.noise (x/noisescale, z/noisescale, seed/392)

You can still generate an integer seed of 1 to 100k, but divide it down so that your math.noise third value is a float in the range of 0 to 256.

Also, move the local Randomer = Random.new() line outside of your LoadMap function. The way it is right now, your instantiating a new random number generator instance for each random number you need. Not only is this expensive, it’s not necessarily even good randomness; it all depends on how the Random class is seeded internally. How you’re meant to use Random is to make one generator with Random.new() at the top of your file, and then repeatedly call NextNumber() on that same instance.

i did both stuff but still getting caves after 3 attempts on the game management script
but not on the test generation script
which is still not answered on why it works normally with the test generation script and not the game management yet

i found the issue finally by myself
i was using Event.Event:Connect(function()
instead of Event.Event:Wait()
which would run the code i guess more times and break it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.