Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Perlin noise generation keeps putting blocks in the same position? [SOLVED]

Im trying to make a minecrafty game and the generation technique i was using worked, but it didn't allow for proper block placing, so i made a block template that has buttons on all sides to accurate detect which side the player clicks on but the generation script keeps putting all of the blocks at the world origion

block = game.ReplicatedStorage:WaitForChild("BlockTemplate")
mapxsize = 15
mapysize = 15
mapzsize = 15
seed = math.random(0, 10000000)
noisescale = 10
amplitude = 10
blocksize =block.Size


for x = 0,mapxsize do
	for z = 0,mapzsize do
		for y = 0,mapysize do
			xnoise = math.noise(y/noisescale, z/noisescale, seed)*amplitude
			ynoise = math.noise(x/noisescale, z/noisescale, seed)*amplitude
			znoise = math.noise(x/noisescale, y/noisescale, seed)*amplitude
			
			density = xnoise + ynoise + znoise + y
			if density < 20 and density > 10 then 
				part = block:Clone()
				part.Name = "Block"
				part.Parent = game.Workspace.TerrainFolder
				part.Anchored = true
				part.Size = Vector3.new(blocksize, blocksize, blocksize)
				part.CFrame = CFrame.new(x*blocksize, y*blocksize, z*blocksize)
			end
		end
	end
	wait()
end
print("Generation Done")

1 answer

✓ Accepted answer

You aren't correctly making your CFrames for each block, you are giving it 3 Vector3s, when want to give it 3 numbers. So you should be setting it's CFrame like this:

 part.CFrame = CFrame.new(x*blocksize.X, y*blocksize.Y, z*blocksize.Z)

This discussion is preserved as it was. New answers, comments, and votes are closed.