Error "Extends cannot be empty" on Terrain:FillBlock()?

I am getting this error.

18:30:53.603 - Extents cannot be empty
18:30:53.605 - Stack Begin
18:30:53.605 - Script 'ReplicatedStorage.worldgenerator', Line 54
18:30:53.605 - Script 'require(game.ReplicatedStorage.worldgenerator).clear() require(game.ReplicatedStorage.worldgenerator).generateworld(Vector3.new(157, 19, -27), 100, 100)', Line 1
18:30:53.605 - Stack End

when trying to use a Terrain:FillBlock(),
but I got all the arguments right?

I did CFrame > Vector3 > Material, does anyone have a clue to why this happens?

local height = heightnoise(v3(x, 0, z))
			local cellpos = spos + Vector3.new(x, height, z)
			
			terrain:FillBlock(CFrame.new(cellpos), Vector3.new(4, 4, 4), Enum.Material.Grass)

This is literally all that I am doing.

1 Like

Have you tried substituting in some dummy values to see if they work? If not, try that. If it works with dummy values it must be the values you are setting. Also try printing the values to make sure they aren’t empty.

1 Like

Doesn’t seem to have something to do with empty values.
Error sometimes does not appear wiht lower values for some reason but unsure, sometimes it’s random, but none of the values are nil for sure.

Maybe it’s the CFrame? Does it always error if you put the CFrame as 0,0,0?

1 Like

It does seem to appear sometimes at big positions I think.
But again, not sure.
Also I don’t see why it would error at huge positions because I’ve made infinite terrain generators that still work fine at positions beyond 5 million.

I’ve tried using the code you posted and substituted the values and it seems to work for me. Does this occur in the Player or only in Studio?

Edit: It might also be useful if you posted the heightnoise function and whatever spos was for you to see if this only happens on your end

also, sorry for such a late reply

Have you tried to change the y axis value to a higher value I guess?

There is nothing with the height noise function, it’s just a function returning a number between -100 or 100 for generating hills and mountains.

Also I have this issue in Studio but pretty sure it won’t be different in the player version.

The y value must be 0 otherwise it just builds the terrain higher up in the workspace, makes no difference at all.

Does x and y are values of 0?
30chars

X and Z is the current position the terrain is being generated at. It’s like a starting position for where to start generating or where it currently is at.

Is your cellpos within the Terrain’s MaxExtents? If not it will throw this error.

Not so sure about that tbh, I generate terrain by placing 4,x,4 (studs) cells and run that through a x and z loop.

Actually, I have never used region3 before.
I usually write a snap function like

local function snapgrid(x)
 return math.floor((x / 4) + 0.5) * 4
end

for snapping things to grid, might try out this region3 thing.

Hey have you ever found a solution, I’m running into this problem and would appreciate some help

1 Like

It may appear at high value like 33554396

When you make terrain through the means of position, it is very important that the values of the first vector are lower than the second’s. It’s a little known fact about terrain and I also ran into a similar issue for a game I was making.

I recently encounter this bug, and it appears to be a float point issue. One of my wedges position was extremely far away like math.huge far away, and it had this problem. You will need to check for parts that is extremely faraway from the origin and remove them before fill block.