So I am wanting to create a system where trees are randomly spawned around the map to save me time. The map terrain has varying elevations so how can I make sure the trees do not spawn at an elevation of which they are in the air or underground. Currently the trees are set to spawn at the same elevation but this presents a problem with hills.
trees = 0
repeat
trees = trees + 1
wait(0.1)
print(trees)
local tree = game.Lighting.Tree:Clone()
tree:Clone()
tree.Parent = game.Workspace.Trees
tree:MoveTo(Vector3.new ((math.random(-2045, 2045)),-7,(math.random(-2045,2045))))
until trees == 1000

1 comment
http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartOnRay in this case, you will want to look at the second returned Vector3 value to determine Y position