How to properly use :ToWorldSpace()

so basically what i have is a huge landscape that I’m trying to bake a bunch of “grass” instances onto it, basically just a bunch of base parts that I don’t want to place manually. So I am trying to set it up so that it places these instances just at the surface, using a little randomization and setting some limits. But the problem I’m running into is that when using :ToWorldSpace() , i notice that not all my parts were rotated the same way, so when I find the space that can fit these instances it actually could be rotated sideways and doesnt work

if the picture does any justice, i tested it and you can see some of these parts are rotated and not on the top, and if i were to set it to normal object space seems like a bandaid on a bigger problem in the future. If anyone can point me in the right direction, like some neat function that sets the face of the object to always be upwards idk, thank you anyways

if you want to make it always face it to upwards, you can recrate a cframe from stratch with just only position of the element

I am instead learning about upvectors which may or may not come in handy, not sure yet

You can read upvector but you can’t set it without CFrame.LookAt, i don’t think that it will be handy for you

1 Like

ok I like the idea of recreating it from scratch But unfortunately im still missing a few things. If i am going to make a box the same size of the part I need to know the X and Z size. Im certain some other CFrame function is needed here, I’m just not sure which to use and I’m not familiar with all my options available to me.

i did not understand well, can you explain what you missing and why more detailed?


in the picture above, you can sort of see in the bottom left, those are basic “grass” models, and I want those to be place just above the green area on the right. The red area is simply a placeholder for visuals, I want the grass models to be scattered all over the red area just to give some of my builds more detail. however in order to find the red area, I need to find the size of all the parts etc. and since Im using the gap fill plugin, not all the parts are the same orientation.

My first attempt was to make a clone of every single part and then find the space inside that part, which workedfind. However, this seems far less precise and took up a lot more memory as I was creating and deleting a huge quantity of parts. I was basically just hoping to find a simpler solution and maybe try something new during the process.

I just want to know, are you focused to generate seeds in game or you just trying to make them placed with Run a command, or are you trying to make a plugin

it’s answer is important for me to talk about best solution

I think both would work, I was only planning on making a function run when the game loads.

than i suggest you this plugin with this settings
Ekran Resmi 2022-08-03 05.57.32

im sorry but the idea was that I make it myself.

i don’t suggest to waste in game server sources to generate seeds if you are not forced to.
but if there is no other way for you i think these steps for a script can generates seeds like you want

  1. define a Y value for starting position of rays
  2. define a zone with starting and ending X’s and Z’s
  3. get a random X and Z between starting and ending values
  4. make a ray to bottom of world on that X and Z and get the position that ray found
  5. clone the seed set it’s CFrame like, Y, Z))
  6. repeat from 3nd line x times
1 Like

alright, thank you so much for your help this was super useful, I have decided that the way I was going about it wasn’t the smart way by any means and I will be trying something different. However, I am still interested if you think there is a way I could’ve done this? I’m learning still and trying new things is always good for growth I think. any ideas?