# Dropping bombs randomly for bomb survival minigame

I am willing to make a bomb survival minigame, but there’s something I can’t figure out. That is how you would pick where the bomb(s) drop.

What I want to do is make each bomb drop in a random location within a specific place. I haven’t figured out how to do this. What’s a good way to do this? (sorry I don’t really mess around with workspace things much.)

3 Likes

Well an easy way to do this is to place the bombs literally all around the map with a number then use math.random() to pick which bomb to drop.

1 Like

Yes, but that seems inefficient. What’s a more efficient way of doing it? If there’s no other better way, I guess I’ll do that.

1 Like

Have a folder of the bomb types.
math.random through them.

Summon it/clone it.

If you want optimization, Object pool it.
(Object pooling is the reusing of parts without destroying them constantly).

And what about the part where you place them in a random position within a specific place?

You can use
local x = math.random(x1,x2) x1 and x2 are the map limits
local y = math.random(y1,y2)
local z = math.random(z1,z2)
bomb.Position = Vector3.new(x,y,z)

Hmm, I see. Thanks for your solution. I will try it and tell you if it works.

I don’t think you intend to change the y component so you can give that a constant value

You could make a folder in server storage called Bombs and place bomb1 bomb2 bomb3 bomb4 etc. Then use something like

local Bombs = game.ServerStorage.Bombs:GetChildren()
local Rand = math.random(1, #Bombs)

Again I’m not a scripter but I’m guessing this method could work?

I already got a better solution by someone. Your method is inefficient and unnecessary.