Spawn Part System In Union Part

Hey :wave:
I have a spawn part system to spawn only in one part region but i don’t know how to spawn only in union part region.

image
I want items spawn only in the red area but they spawn in blue area too.

My current script

local posX = math.random(x-xS,x+xS)
local posZ = math.random(z-zS,z+zS)
local pos = Vector3.new(posX,0,posZ)
1 Like

Is this your only script? Because if so, no one will ever be spawned inside these zones.

Secondly, are both the red and blue parts a union together? Or are they both a model?

No it’s a script to get the position where items must spawn but work only for classic parts.
No red part is a union part and blue is a classic part, blue it’s only to show where items spawn but i don’t want it.


local x = touchZone.Position.x
local z = touchZone.Position.Z
local xS = touchZone.Size.X/2 - 5
local zS = touchZone.Size.Z/2 - 5

You are getting the Position and the Size of the Red partUnion, to know the specific coordinate where the item should spawn, but even if its an union its size still being XYZ, so its a box. Probably thats not a proper approach for your case.

What about, still using the classic parts, all of them inside a folder or model instead of being an union, from that folder you select a random part and then select random coordinates inside that part everytime you want to spawn an item

Yes i think is the best solution. Thank you :pray:.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.