Yes both are on. Now I am really stuck… I did a check function that check the GetPartInPart of model1 and then if it returns true with the part being in it either a random part of the segment, or the hitbox, it will return false if the table returns either the segment attachments or the Pivot. The segment attachments are tiny parts that other pivots can attach too, and the Pivots are parts that attach to the segments. When I run the game, only 1 loads and thats it, for some reason it will NOT load the other ones. I will post all my code here I am so stuck someone please help!
local replicatedStorage = game.ReplicatedStorage
local FloorSegment = replicatedStorage
--Modules
local Zone = require(game.ServerScriptService.Modules.Zone)
local ZoneManager = require(game.ServerScriptService.Modules.Zone.ZoneController)
--these change how big it can get
local MaxSegmentDepth = 100
local MaxSegments = 100
local SegmentCount = 0
export type Segment = {
Connections : {Segments}
}
local FloorSegmentTree = {
}
local SegmentZones = {
}
local module = {}
local timesRan = 0
local function shuffleList(list)
for i = #list, 2, -1 do
local j = math.random(1, i)
list[i], list[j] = list[j], list[i] -- Swap elements
end
return list -- Return the shuffled list
end
function CheckIfTouching(model1)
if not model1 then return end
local parts = workspace:GetPartsInPart(model1.HitBox)
local modelTouched
for _, part in parts do
if part.Name ~= "Pivot" or part.Parent ~= "SegmentAttachments" or part.Name == "HitBox" then
return true
else
return false
end
end
end
function CreateSegment(Depth, LastObject, LastObjectConnectionCFrame)
wait(1)
if Depth >= MaxSegmentDepth then
print("max segment length reached")
return false
end
if SegmentCount >= MaxSegments then
print("max segments reached")
return false
end
if LastObject == nil then -- Make the base the first thing that spawns in
local newFirstOBJ = replicatedStorage.FloorSegments.Base:Clone()
newFirstOBJ.Parent = workspace
CreateSegment(Depth+1, newFirstOBJ, newFirstOBJ.Pivot.CFrame)
end
local posibleSegments = replicatedStorage.FloorSegments:GetChildren()
local randSegment = posibleSegments[math.random(1, #posibleSegments)]
--if LastObject.Name == "Base" and randSegment.Name == "Base" then
--CreateSegment(Depth, LastObject, LastObjectConnectionCFrame)
--end
local clonedSegment = randSegment:Clone()
clonedSegment.Parent = workspace
local isTouching = CheckIfTouching(clonedSegment)
if isTouching then
clonedSegment:Destroy()
CreateSegment(Depth, LastObject, LastObjectConnectionCFrame)
end
SegmentCount += 1
clonedSegment:PivotTo(LastObjectConnectionCFrame)
CreateSegment(Depth+1, clonedSegment, clonedSegment.Pivot.CFrame)
-- IDK why we needed this right here I kinda understand the script but im still confused also its 2AM so i might be dumb
-- but for now it kinda works
--local SegmentConnectionContinues = clonedSegment.SegmentAttachments:GetChildren()
--local Segments = {}
--for i, connection in ipairs(SegmentConnectionContinues) do
--table.insert(Segments, CreateSegment(Depth + 1, clonedSegment, connection.CFrame))
--en-d
--return Segments
end
function module:GenerateFloor(floorNumber)
SegmentZones = {}
FloorSegmentTree = {}
SegmentCount = 0
FloorSegmentTree = CreateSegment(0, nil, CFrame.new(0, 2, 0)) -- Make last obj = nil because we don't have a last OBJ the first time
end
return module
Forget the other random stuff in their as its just a test baseplate to work into a project I am working on, but there it is. I call the :GenerateFloor on the server script once the game starts. I will also show a screenshot of the Explorer:
Basically the plan was to Generate random and infinite (Well not infinite) Segments to create 1 Floor. The reason why I did nil for the first OBJ is b/c when it runs the first time it will not have an OBJ, so I catch the nil and call the base
in REP which is the fiirst one I want to spawn. After that, I want it to dominoe and keep going with the segments but obviously that’s not happening.
This is what is occuring… Only 1 spawns and thats it