How can I randomly place a part on a random wall?

What do you want to achieve?

I want to be able to spawn a part at a random X/Z (if X-axis is more dominant that on it should be on the X) position on a random wall (from a folder/model with three other walls all forming the shape of a box) if the wall is longer on the X then it needs to choose a random position on X, y shouldn’t be random, same for z as x

What is the issue?

The methods I’ve tried included ray casting and offsetting CFrames, which may not be an incorrect approach but the problem is I don’t have a solid grasp on either topic so I cannot debug/write my own code.

What solutions have you tried so far?

I’ve searched for potential methods on the Dev Forum but didn’t really fit my exact situation. I’ve also asked a colleague but their methods have not worked either.

Thanks for reading, and please try to explain why you do what you do in the code.

3 comments

0

I think I get what this is supposed to mean, but a wall has 2 sides for the X and 2 sides for the Z axis. Which one would you want to put the part on?

0

I'm not entirely sure what you mean but it should just place a part on the axis which is more dominant. I already have a script which does that and names the wall accordingly (Wall.Name = "X" or Wall.Name = "Z"

0

so um, whats the problem. Do you want the entire code doing everything u listed, or is there an error happening somewhere in ur script.