Sigh, I looked at a tutorial and stupid me THOUGHT could understand it. I didn't really understand the tutorial even tho I rewatched it.
This is the progress even tho the script doesn't work:
```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TilesFolder = ReplicatedStorage:WaitForChild("Tiles")
local HallwayTemplate = TilesFolder:WaitForChild("HallwayTile")
local MAX_TILES = 40
local queue = {}
local function isSpaceOccupied(cframe, size)
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.FilterType.Include
overlapParams.FilterDescendantsInstances = {workspace}
local parts = workspace:GetPartBoundsInBox(cframe, size, overlapParams)
for _, part in pairs(parts) do
if part:IsDescendantOf(workspace) and (part.Parent:IsA("Model") or part.Parent.Parent:IsA("Model")) then
return true
end
end
return false
end
local function spawnTile(template, targetPoint)
local newTile = template:Clone()
local newPoints = {}
for _, p in pairs(newTile:GetDescendants()) do
if p.Name == "ContinuePoint" then
table.insert(newPoints, p)
end
end
if #newPoints == 0 then
newTile:Destroy()
return nil
end
local myEntryhed = newPoints[math.random(1, #newPoints)]
local connectionCFrame = targetPoint.WorldCFrame * CFrame.Angles(0, math.pi, 0)
local currentOffset = myEntryhed.WorldCFrame:ToObjectSpace(newTile:GetPivot())
local finalCFrame = connectionCFrame * currentOffset
local _, size = newTile:GetBoundingBox()
if isSpaceOccupied(finalCFrame, size * 0.9) then
newTile:Destroy()
return nil
end
newTile:PivotTo(finalCFrame)
newTile.Parent = workspace
for _, p in pairs(newTile:GetDescendants()) do
if p.Name == "ContinuePoint" and p ~= myEntryhed then
table.insert(queue, p)
end
end
return newTile
end
local starter = workspace:WaitForChild("StarterTile")
for _, p in pairs(starter:GetDescendants()) do
if p.Name == "ContinuePoint" then
table.insert(queue, p)
end
end
local count = 0
while #queue > 0 and count < MAX_TILES do
local point = table.remove(queue, math.random(1, #queue))
if point and point.Parent then
if spawnTile(HallwayTemplate, point) then
count = count + 1
task.wait(0.05)
end
end
end