How to use FillBlock()

i tried to make a terrain generator script and its not filling the block with terrain

PartStorage.ChildAdded:Connect(function(child)
	workspace.Terrain:FillBlock(CFrame.new(child.CFrame, child.Size, Enum.Material.Grass))
end)
1 Like

Replace with: workspace.Terrain:FillBlock(child.CFrame, child.Size, Enum.Material.Grass)

this is the whole script and that doesnt work

local PartStorage = workspace:WaitForChild("PerlinNoise_Storage")

local Size = 400
local res = 100
local freq = 4
local amplitude = 10

local generatedSeed = math.random()
print(generatedSeed)
local function getHeight(x, z)
	local noiseHeight = math.noise(x/res*freq, z/res*freq)
	noiseHeight = math.clamp(noiseHeight, -0.5, 0.5) + 0.5
	return noiseHeight
end

for x = 0, Size do
	for z = 0, Size do
		local part = Instance.new("Part")
		part.Parent = PartStorage
		part.Anchored = true
		part.CanCollide = false
		part.CastShadow = false
		part.Size = Vector3.new(1, 1, 1)
		
		local height = getHeight(x, z)
		part.Position = Vector3.new(x, height * amplitude, z)
		part.Color = Color3.new(height, height, height)
	end
	
	game:GetService("RunService").Heartbeat:Wait()
	
end


PartStorage.ChildAdded:Connect(function(child)
	workspace.Terrain:FillBlock(child.CFrame, child.Size, Enum.Material.Grass)
end)```

If you were to print(height), does it print 0?

it prints 0.28188418 and a bunch of other ones

Multiply it by 10 or 100 depending on how intense you want it to be. Iā€™d recommend 10.
local height = getHeight(x, z) * 10 --or 100
Noise usually returns numbers ranging from -1 to 1.

oops, it doesnt work even tried 100

i figured it out!!

for _, v in pairs(PartStorage:GetChildren()) do
	local terrain = workspace.Terrain
	terrain:FillBlock(v.CFrame, v.Size, Enum.Material.Rock)
end