I’m wanting to make it so ores generate with a chance as you go lower in the quarry, but I’m not sure how. I want it so that ores generate with a chance via math.clamp(Y,1,30). However, I don’t know how to make it so it clamps it properly instead of going 50 studs down it goes from one to thirty. Sorry for poor explanation.
local function selectOre(ore, Y, NoLava)
local choice = math.random(1,100)
if choice >80 and choice <90 then
local orechoice = ores[math.random(1,#ores)]
ore = orechoice
elseif choice >=50 and choice <=52 and Y >-1000 and Y <-1000 then
local uncommonchoice = uncommonores[math.random(1,#uncommonores)]
ore = uncommonchoice
elseif choice >=30 and choice <=31 and y <-2500 then
local rarechoice = rareores[math.random(1,#rareores)]
ore = rarechoice
elseif choice >=0.1 and choice <=1 and Y <-4000 then
local legendarychoice = legendaryores[math.random(1,#legendaryores)]
ore = legendarychoice
elseif choice >5 and choice <5.5 and Y <-5000 and NoLava == nil then
ore = game.ReplicatedStorage.Ores.Lava --Lava
elseif choice >70 and choice <=100 and Y >-200 then
local solidorechoice = solids[math.random(1,#solids)]
ore = solidorechoice
else
if Y >-100 then
ore = game.ReplicatedStorage.Ores.Dirt
elseif Y <-100 and Y >-4000 then
ore = game.ReplicatedStorage.Ores.Stone
elseif Y <-4000 and Y >-7000 then
ore = game.ReplicatedStorage.Ores.Basalt
elseif Y <-7000 then
ore = game.ReplicatedStorage.Ores.Hellstone
end
return ore
end
return ore
end
EDIT: I’ve not put the whole script in, since I’m worried it can be copied off of.