#Spawning parts randomly inside a set area/range

10 messages · Page 1 of 1 (latest)

exotic frigate
#

Like a bossfight mechanic with asteroids raining down I want to spawn parts with random positions that are still inside the same range of the length and width of my arena area: (212, 46, 209)

Can anyone help me with this?

maiden knot
#

So the length is 212 & the width is 209?

#

Am I right?

#

Actually the length is both 212 and 209

#

I think

exotic frigate
#

yeah

maiden knot
#

I'm going to give you an idea on how to summon parts with random positions. And I'll let you work with the other components.


local XAxis = math.random(212, 213)
local ZAxis = math.random(209, 210)

for i=0, 10, 1 do -- meteor spawns
local newPart = instance.new("Part", workspace) 
newPart.Size = vector3.new(20,15,20)
newPart.Name = "Meteor"
newPart.Position = vector3.new(XAxis, 20, ZAxis)
wait(1)
end
#

Idk if the Math.random should be inside the for loop

#

But if it doesn't give new positions just switch the XAxis & ZAxis place inside the for loop

obsidian creek