First, you still using the boxFrame, as I said you need to supply a new random one based on your base part. You should at least try those suggestions, otherwise its complex to progress on your topic.
Look I took a few minutes to build a random placement script that clones a model which has 3 parts, and place it in a random position of a baseplate, it avoids the parts to intersect with each other, it will retry until finding enough room to place the model, and it lands it on the baseplate, it will work for any model size nicely:
until workspace:GetPartBoundsInBox(testPos, boxSize) == {v} or workspace:GetPartBoundsInBox(boxFrame, boxSize) == {place, v} -- make that thing work later
And you fixed that line which you commented as “make that thing work later”?
Cause that line makes no sense to me.
I did it like this and it works as expected:
repeat
-- CODE THAT GETS THE RANDOM COORDINATES
-- CREATING THE CFRAME WITH THE RANDOM COORDS
newRandomCFrame = CFrame.new(randomX, basePos.Y + baseSize.Y/2 + boxSize.Y/2, randomZ)
-- MAX ATTEMPS
attempts = attempts + 1
until #workspace:GetPartBoundsInBox(newRandomCFrame, boxSize, overlapParams) == 0 or attempts >= maxRetries
-- RESULTS
if attempts < maxRetries then
model:PivotTo(newRandomCFrame)
model.Parent = workspace.Folder
else
warn("Failed to find a empty position after 10 retries")
end
You will use overlapParams as blacklist or whitelist in order the GetPartBoundsInBox exclude some parts inside the area that is checking. Like, you want to exclude the baseplate, otherwise it wont find free space if the baseplate is inside that area.
That doesnt matter, turn it into global if you need it as that. The thing, is that you can create the params in the script and then use it when your loop runs to check the specific area you need