I'm trying to make it so it can calculate a position from all 4 top corners and the middle of the top 4 sides of a part.
Every time I run this function it keeps printing out (0, 0, 0) even though the Part isn't positioned at the origin.
local vector3 = Vector3.new local random = Random.new() local function returnRandomPos(objectPos, objectSize) local posLibrary = { vector3(objectPos + vector3(-objectSize.X, 1.5, -objectSize.Z)), vector3(objectPos + vector3(objectSize.X, 1.5, objectSize.Z)), } local index = random:NextInteger(1, #posLibrary) return posLibrary[index] end local object = workspace.Part local randomPos = returnRandomPos(object.Position, object.Size) print(randomPos)
Hopefully this helps in some way:
local function returnRandomPos(objectPos, objectSize) local posLibrary = { objectPos * Vector3.new(-objectSize.X, 1.5, -objectSize.Z), objectPos * Vector3.new(objectSize.X, 1.5, objectSize.Z), } return posLibrary[math.random(1, #posLibrary)] end local object = workspace.Part local randomPos = returnRandomPos(object.Position, object.Size) print(randomPos)