Help with Model/Part Position?


I am working very hard on Spawn Stuff! I have one major problem that needs to be fixed! I want to fix a problem with the position of spawning models and parts!

Here is a picture of what i am trying to reference

The massive red circle indicates where i want the stuff to spawn in.
But this is what it looks like right now:

I want the stuff to be everywhere (except behind and in the button as of the picture before).
Here is a random postition for a model:

	elseif event == 35 then
		local dunbuggy = game.ServerStorage.DuneBuggy:Clone()
		local position =, 12),69.414,math.random(-124, 33))
		local cf =
		dunbuggy.Parent = workspace

Here is a random postition for a part:

	elseif event == 36 then
		local speedcoil = game.ServerStorage.SpeedCoilProp:Clone()
		speedcoil.Parent = workspace
		speedcoil.Position =, 12),3.5,math.random(-124, 33))

Please comment a solution to this problem!
Cheers! :wink:

What does your script look like. We can’t help if we don’t know what we are working with.
So what you are saying is you’d like your models to spawn randomly all over the green baseplate?

I’m assuming this is random spawns? If it’s truly something you want random and allow for odd terrain, set yourself up with a part maybe 100 studs above the ground, choose a random vector in that part and send a Raycast down till it hits the ground and places a part there. (Overlaps may happen)

Another option that gives more control is using parts in a folder as spawn locations, storing those in an array and randomly choosing one then placing the part/mesh on that location this gives you more control but requires you to actually place spawn locations.

Oh yeah sorry, forgot to add it!

How big is the green baseplate?
Your script only randomly chooses an area that is 126 studs by 157 (math.random(-114, 12),69.414,math.random(-124, 33)) studs, which isn’t that big.
If you try to spawn a lot of items in a relatively small area then they will probably overlap.

Well, here is the size of where i want everything to spawn in: 960, Z, 596
But if you want the size of my actual baseplate, here: 1004, 16, 984

Also, I don’t really mind them overlapping each other but if you can fix that, then you may do that as well (if you want to), anyways i hope this might help!

Keep in mind that the Z is just the letter because some of my models and parts are tall and have to spawn in a certain height (Like the pillars in the 2nd image from the post).

Actually Z is Y, as in X,Y,Z but I figured that’s what you were doing for the height already.

If your spawn is at 0,0,0 and your spawn area is also centered there then your x value math.random numbers should be (-480,480) and your z values should be (-298, 298).

To find your actual world space you could put a Part at the corners of the area you want your stuff to spawn in to get those coordinates.

Thank you for the response, but I am still having problems with it. The pillars are spawning only on the right side and not the left, and they are also spawning a little bit off of the baseplate, they are also spawning behind the button which shouldn’t happen.

Here is an image of what I’m trying to say:

The four red circles are the parts which you have recommended and the blue lines are the border for where the stuff spawns in.
Here is another image of the pillars spawning incorrectly:

I’m not sure what else to do!

Are the pillars supposed to be at the corners, or randomly selected spots in the blue rectangle? You showed a picture but didn’t explain why they were incorrect (I can’t read your mind).
If you want them at the corners then spawn them at those Positions, not at math.random locations.

They need to spawn randomly in the blue rectangle

Okay, so place a Part (let’s call it Spawn) that is the size of the blue rectangle where you want your Models and Parts to spawn. For your example “the size of where i want everything to spawn in: 960, Y, 596
The Position of Spawn is the center of the area. Just for example let’s say it’s at X=0, Z=500. You can modify the numbers below to make it fit your exact requirements.
The limits are going to be plus or minus half the X and Z values of Spawn.
So your X limits would be (0 plus and minus 1/2 of 960) so (-480,480).
Your Z limits would be (500 plus and minus 1/2 of 596) so (500-298,500+298) so (202,798)

That means your script for random spawning the dunebuggy would be:

elseif event == 35 then
		local dunebuggy = game.ServerStorage.DuneBuggy:Clone()
		dunebuggy.Position = (math.random(-480, 480), 69.414, math.random(202, 798))
		dunebuggy.Parent = workspace

If the DuneBuggy model is 10x20 studs then you may want to shrink the limits of your math.random sections by 1/2 those values on each side. That would make it:
dunebuggy.Position = (math.random(-475, 475), 69.414, math.random(212, 788))