Introduction
Some time ago I posted this question, which was solved long time ago. I had to stop the project due to personal reasons and now I'm back at it as a hobby.
Problem
The parts I generate have a random generated size which presents a problem when I try to Instance on the map as those overlap others.
A bit of Code
--Creates the parts
local function CreatePart()
local part = Instance.new("Part")
part.Name = "Reservoir"
part.Anchored = true
part.BrickColor = BrickColor.Black()
part.Size = Vector3.new(math.random(10, 50), 0.5, math.random(10, 50))
local reserves = Instance.new("IntValue", part)
reserves.Name = "Oil"
reserves.Value = math.random(100, 1000);
return part
end
--creator loop
for i = 0, resCount, 1 do
local part = CreatePart()
local NewVector = RandomVector3()
while CheckTableForPosition(NewVector) do
NewVector = RandomVector3()
end
--get length of array with #arrayName
PastPositions[#PastPositions+1] = NewVector
part.CFrame = CFrame.new(RandomVector3())
part.Parent = workspace
wait()
end
