Title explains it all.
–Minimum character limit
Title explains it all.
–Minimum character limit
When you do Zone.new(region)
, you get back a Zone
object, which has a property region: Region3
. To get a random position inside the Region3 do:
local region = zone.region
local x, y, z = region.Size.X, region.Size.Y, region.Size.Z
local randomPosition = Vector3.new(
x.Position.X + math.random(-x,Size.X / 2, x.Size.X / 2),
y.Position.Y + y.Size.Y / 2,
z.Position.Z + math.random(-z.Size.Z / 2, z.Size.Z / 2))
)
For some reason this doesn’t work. I think it’s because you’re doing X.Position.X when “X” is simply just a number(the x coordinate of the zone)
Oops mah bad
local region = zone.region
local x, y, z = region.Size.X, region.Size.Y, region.Size.Z
local randomPosition = Vector3.new(
region.Position.X + math.random(-x / 2, x / 2),
region.Position.Y,
region.Position.Z + math.random(-z/2, z / 2))
)
I got the error " Position is not a valid member of Region3" on line 13 for some reason
Ahh mb,
local region = zone.region
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))
)
Thanks, it worked!
–Minimum character limit
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.