Math.noise returns zero when generating terrain

So, Im trying to create a procedural terrain generation, and I made a script that should work.

It uses perlin noise (math.noise) to determine the height of each part that is created, but the noise only returns 0 or -0. Im not sure why. Here is the code im using:

xcoord = 0
zcoord = 0

loopx = 0
loopz = 0

while loopz < 100 do
	while loopx < 100 do
	loopx += 1 -- step x values loop --
		
    	part = Instance.new("Part") -- create part --
    	part.Anchored = true
    	part.Parent = workspace
    	part.Size = Vector3.new(1,1,1)
    	part.CFrame = CFrame.new(Vector3.new(xcoord,math.noise(xcoord,0,zcoord),zcoord,math.random(1,100000)))

	
	xcoord += 1
end 
loopz += 1 -- reset x values and step z values --
loopx = 0
zcoord += 1
xcoord = 0

wait(0)
print("looped")

end

thanks!

With Roblox’s default noise function, using integers for X, Y and Z will always return 0. You could try dividing xcoord and zcoord:

local noiseScale = 128

part.CFrame = CFrame.new(Vector3.new(xcoord,math.noise(xcoord/noiseScale,0,zcoord/noiseScale),zcoord,math.random(1,100000)))
2 Likes

Thanks! I didnt know you couldnt use integers for the noise function. It works good now.