Making a procedural generation enum error

Hi everybody, I am making an ocean exploration game. Now I am trying to use value for Terrain:FillBall third argument because I am using numbers from math.random to fill the material. I cant use enum.material because I don’t know how to convert an enum number into a real number. Does anybody have any ideas on how to do this?
script:

local seed = Random.new():NextNumber(1, 100000)
local mat = math.random(1,2)
local aaa = nil
local aa2 = nil
local aa3 = nil
local FirstGenerate = math.random(#Enum.Material:GetEnumItems())
local SecondGenerate = math.random(#Enum.Material:GetEnumItems())
local ThirdGenerate = math.random(#Enum.Material:GetEnumItems())

for x = -1000, 1000 do
for z = -1000, 1000 do

	local noise = math.noise(seed, x/70, z/70) * 50
	if noise < 1 then
	workspace.Terrain:FillBall(Vector3.new(x,noise,z),2,FirstGenerate)
	end
	
	if noise > 1 and noise < 2 then
		workspace.Terrain:FillBall(Vector3.new(x,noise,z),2,SecondGenerate)

	end
	if noise > 5 then
		workspace.Terrain:FillBall(Vector3.new(x,noise,z),2,ThirdGenerate)
		end
	
	
end

end

Probably something like this is what you want to do, since GetEnumitems returns a table, you can just reference it with a random number

local materials = Enum.Material:GetEnumItems()

local FirstGenerate = materials[math.random(#materials)]
local SecondGenerate = materials[math.random(#materials)]
local ThirdGenerate = materials[math.random(#materials)]
2 Likes

Thanks! it works! Thank you so much!

2 Likes