I’m trying to make parts spawn within a zoneplus zone, but their Y position never changes no matter how small I make the part the zone is based off. Here is my code:
local function generateRandomPosition(region: Region3)
local x, y, z = region.Size.X, region.Size.Y, region.Size.Z
local position = region.CFrame.Position
local randomPosition = Vector3.new(
position.X + math.random(-x / 2, x / 2),
position.Y,
position.Z + math.random(-z / 2, z / 2)
)
return randomPosition
end
if it’s a zoneplus zone then you can just use :getRandomPosition or something like that. Otherwise just use this
local function generateRandomPosition(region: Region3)
local x, y, z = region.Size.X, region.Size.Y, region.Size.Z
local position = region.CFrame.Position
local randomPosition = Vector3.new(
position.X + math.random(-x / 2, x / 2),
position.Y + math.random(-y / 2, y / 2),
position.Z + math.random(-z / 2, z / 2)
)
return randomPosition
end