-
What do you want to achieve?
A Maze That Uses Random Pieces But Doesn’t Overlay -
What is the issue?
The Maze Stops Generating Due To RayCasts Finding Something -
What solutions have you tried so far?
Removing The RayCast Part which ended up in the pieces OverLaying
this is the code
while wait() do
print("while wait loop")
for t = 1,1000 do
for i,v in pairs(game.Workspace.Maze:GetChildren()) do
print("Locating maze parts")
local attachment2 = v:FindFirstChild("Attachment")
local parts = game.ReplicatedStorage.MazeParts:GetChildren()
local order = math.random(1,3)
for i,v in pairs(v:GetChildren()) do
if v.Name == "Attachment" then
print("Attachment")
wait()
end
end
if attachment2 ~= nil then
print(attachment2)
newpart = parts[order]:Clone()
v.Attachment.Orientation += Vector3.new(0,180,0)
local attachment2 = v.Attachment
local attachment1 = newpart.ConnectionAttachment
--Result1
local RayOrigin1 = attachment2.WorldPosition
local RayDirection1 = attachment1.WorldCFrame.LookVector
local Length = newpart.Size.Z
local resultZ = workspace:Raycast(RayOrigin1, RayDirection1 * Length)
local Width = newpart.Size.X
local resultX = workspace:Raycast(RayOrigin1, RayDirection1 * Width)
if resultZ then
newpart:Destroy()
else
--Result2
newpart.Parent = game.Workspace.Maze
newpart.CFrame = attachment2.WorldCFrame * attachment1.CFrame:Inverse()
attachment2:Destroy()
attachment1:Destroy()
--ammount = 0
wait()
end
end
end
end
end