How do i clone stuff in a random position in a region?

I want to make a script which clones something and spawns in a random position (X-axis) in a region (made by a part)

But i don’t know how to randomly clone it in a position.

What i do is set multiple spawners and randomly spawn the object in a random spawner, but looks kinda bad, and might cause lag. I hope you help me :+1:

[I want to clone parts in a region and place them at a random position?]

1 Like

So, if I have interpreted your question correctly, you want to clone parts in a region and place them at a random position?

Yeah. 30charsucksrightlolxdyey

Do they spawn together at the same position, or they’re all at different positions

At different positions (Models or parts)

You can use FindPartsInRegion3 and find all of the parts in the region, then generate a random CFrame and position it. If the part is from a model,you’ll have to find that model, clone and position it. You’ll have to register that it’s already cooked in a table,so that it’s not cloned again

I think this might be what you are looking for: Help with an Agar.io like spawn and generation system - #2 by 1Joeb

Well, you simply create a random Vector3 where each of its components (x, y, z) is a random number between each of the components of the two vectors that you used to define that region.

local v1 = Vector3.new(2,2,2)
local v2 = Vector3.new(5,5,5)

local v3 = Vector3.new(math.random(v1.X, v2.X), math.random(v1.Y, v2.Y), math.random(v3.Z, v3.Z))
2 Likes