I want to make a realistic tree generation. This is the script i came up with:

local model = Instance.new("Model")
model.Name = "Generated"
counter = 0
repeat
counter = counter + 1
wait()
model.Parent = game.Workspace
local tree = game.workspace.Tree:Clone()
tree.Parent = model
tree.Position = Vector3.new(math.random(-1023.5,1023.5),8.655,math.random(-1153.5,893.5))
tree.Orientation = Vector3.new(-9.77,math.random(0,360),43.25)
until counter == 3000
print("Done making trees")

It works fine. No bugs, Or anything. The script only works if the plane the trees are on is flat. But now i am tired of the flat plane and make it seem more realistic. I just want know what the height of the highest terrain (not a part) is at x and z. Sorry for my bad english.

Also, give me an explanation of how it works.

6 comments

1

Is this post be gonna unanswared?

0

I'm struggling to find the answer to this issue too. I know that Widgeon and I believe Crazyman32 have done it, but none of them have the code open source.

0

Oh.

0

Suggestion: raycast from a high Y height (higher than your terrain will ever go) and use the Y value of the hit position from FindPartOnRay.

0

???

0

Future hasanchik here, and i could tru that