Hi Other Developers,
I’ve been having some trouble with random obby generation.
Here is my script:
local GenerationID = 1
for _, Section: Model in RandomGenFolder:GetChildren() do
Section:Clone()
Section.Parent = game.Workspace:WaitForChild("Sections")
Section.PrimaryPart = Section:FindFirstChild("endpoint")
Section.Name = GenerationID
if GenerationID > 1 then
print("Ran")
Section.PrimaryPart.CFrame = game.Workspace.Sections:FindFirstChild(tostring(GenerationID - 1)):FindFirstChild("startpoint").CFrame
end
GenerationID += 1
end
What this script is doing is getting the endpoint of a section of the obby and then setting the cframe to the startpoint of the section infront of it.
local GenerationID = 1
for _, Section: Model in RandomGenFolder:GetChildren() do
Section:Clone()
Section.Parent = game.Workspace:WaitForChild("Sections")
Section.PrimaryPart = Section:FindFirstChild("endpoint")
Section.Name = GenerationID
if GenerationID > 1 then
print("Ran")
Section:SetPrimaryPartCFrame(game.Workspace.Sections:FindFirstChild(tostring(GenerationID - 1)):FindFirstChild("startpoint").CFrame)
end
GenerationID += 1
end
This uses the SetPrimaryPartCFrame method that moves all the other parts along with it. Do note however that it’s deprecated, and replaced with the :PivotTo() method. If you wanna implement that then you need to first put it somewhere in the workspace, get the distance (subtract last endpoint vector3 from primary part vector3)