Hi Guys, so basically I have a loop and it’s behaving really weirdly.
Code -
local X = 200
local Z = 100
local previousOffset = 0
for x=1, X do
for z=1, Z do
print(previousNoise.." - Before") -- basically here, for some reason, it's printing 17500 and it's weird.
local noise = math.noise(x/X, z/Z, 100) * 2
local y = math.ceil(noise + previousNoise) * 4
previousNoise += 1
--print(y)
end
end
So basically even at the start of the loop, it’s starting from 17,500 and I dont really know why. Any help is appreciated. Thanks
Your code doesn’t show where the variable prevousNoise is being initialized, if your comment says it prints 17500 that that line, then obviously the only thing that could be 17500 is that variable.
Now you fixed your code, now I see the problem. You forced the loop to execute itself instantly without waiting, which resulted in it creating tens of thousands of prints in an output that can only contain a few thousand of them - this is why the first print that you see says “17500” or in my case “15000”. Add a “task.wait()” after every ‘for do’ loop.