How could I spawn ores in a terrain cave?

Hello!

I’m working on a cave system which is all-terrain, I have models that are in ServerStorage that my goal is to clone them to sides of my terrain caves (picture provided below). I’m not quite sure how to do this.

Images:
Cave
Ores

If you can help it is greatly appreciated, if not, no worries I hope you have a great day!

You could easily use Random to create a Ray that travels a random direction from a middle location( the center position of your cave ). Then detect the hit position of the Ray, and teleport your ores there.

You could probably do this a bunch of different ways, but this is what I would try something like this first.

Is there an article I can read to read more about this?

1 Like

Here are some resources that use the principles I was referring to:

–use Random() because math.random() isn’t truly random.

–Raycasting

workspace:FindPartOnRay() returns three values, the second one being the hit position. You can use this to find the position to move your rock to.

Hope this helps you out!

1 Like

The third link comes up with an error, but other than that, thank you! I’ll message you if I have anymore questions.

1 Like