BlueTaslem helped me make this offset script. It works pretty well. But if this thing chooses a position that is less then the minimum offset, then it doesn't create the block. I want to fix that.
local minimum = 20
local p = Vector3.new(math.random(-120,-100), workspace.Platform.Position.Y - num1/2 + 0.5, math.random(22,85))
local nearest = math.huge
for _, barrier in pairs(barriers) do
nearest = (barrier - p).magnitude
end
if nearest > minimum then
table.insert(barriers, p)
--blah blah create block stuff
I tried to fix it like this, but it breaks the script
local minimum = 20
local p = Vector3.new(math.random(-120,-100), workspace.Platform.Position.Y - num1/2 + 0.5, math.random(22,85))
local nearest = math.huge
for _, barrier in pairs(barriers) do
nearest = (barrier - p).magnitude
end
while nearest < minimum do
p = Vector3.new(math.random(-120,-100), workspace.Platform.Position.Y - num1/2 + 0.5, math.random(22,85))
nearest = (barrier - p).magnitude
end
table.insert(barriers, p)
--create blocks blah

1 comment
Wasn't the point of your question to only allow blocks that aren't close to each other? If you don't want that check, just remove the
if...