#Tiles Generator

1 messages · Page 1 of 1 (latest)

robust loom
#

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

#

Dang, 2 help forum from me in a row. I feel famous :b

#

blinks

fiery anvil
#

is the script u sent a child of the module in workspace

#

if so something needs to call/require the module

#

and dont keep it in workspace either

#

@robust loom

#

also any output stuff post that

robust loom
#

idk what that module is lkey,,,,

#

imma remove it

#

naybe its empty

fiery anvil
robust loom
fiery anvil
#

are the tiles lined up

#

properly spaced with whole numbers

robust loom
#

can ye please explain ? I am italian and my english is very poor lol

#

also I'm sue it's all good,,,

#

sure*

#

I js don't know why it doesn't work cause

#

the placesments ae correct

#

are*

#

there are tiles with the ContinuePoint that face outside of the tile, if that's correct

fiery anvil
# robust loom wdym ?

so say one part is 3.79491 studs instead of 4 studs, it will mess up placements especially if its piece on the side

#

and you said you followed a tutorial if thats correct

#

maybe someone else faced a similar problem

#

my recommendation is that you re make the tiles if the code works just fine

#

try changing the parts around and changing the size

#

move the continuepoint around too

robust loom
#

I can't still understand,,,,,, The tiles can't be the same size each. Every tile is different.

robust loom
#

I GOT IT TO WORK !! (kinda,,,)

#

(the arrows are for debugging btw)

fiery anvil
#

my apologies