My offset script doesn't work. I have been trying to use print() to find out the magnitude but no luck.
for i = 1, 5 do local barriers = {} local separation = 20 local p = Vector3.new(math.random(-140,-110), workspace.Platform.Position.Y - num1/2 + 0.5, math.random(22,85)) local nearest = 100 for _, barrier in pairs(barriers) do nearest = (barrier - p).magnitude print(nearest) --nothing appears here end if nearest > separation then table.insert(barriers, p) --build offset stuff end
You're trying to loop through an empty table. Since the table is empty, the loop doesn't increment, since you're using pairs.
for i = 1, 5 do local barriers = {} --empty table local separation = 20 local p = Vector3.new(math.random(-140,-110), workspace.Platform.Position.Y - num1/2 + 0.5, math.random(22,85)) local nearest = 100 for _, barrier in pairs(barriers) do --the table is empty, so the loop doesn't run nearest = (barrier - p).magnitude print(nearest) --nothing appears here end if nearest > separation then table.insert(barriers, p) --build offset stuff end