while true do local sides = script.Parent.Folder local Left = sides:FindFirstChild("Left") local Right = sides:FindFirstChild("Right") local Up = sides:FindFirstChild("Up") local Down = sides:FindFirstChild("Down") wait(0.2) local side2pic = math.random(1,4) if Left or Right or Up or Down then if side2pic == 1 then if Left then local partclone = game.Lighting.PartOfMap:Clone() wait() partclone.Part.Anchored = true partclone.Part.Size = Vector3.new(15.86, math.random(0.05,3), 19.21) partclone.Parent = workspace.Map partclone.Part.Position = script.Parent.Position + Vector3.new(15.881,0,0) Left:Destroy() partclone.Part.Folder.Right:Destroy() elseif side2pic == 2 then if Right then local partclone2 = game.Lighting.PartOfMap:Clone() wait() partclone2.Part.Anchored = true partclone2.Part.Size = Vector3.new(15.86, math.random(0.05,3), 19.21) partclone2.Parent = workspace.Map partclone2.Part.Position = script.Parent.Position + Vector3.new(-15.881,0,0) Right:Destroy() partclone2.Part.Folder.Left:Destroy() elseif side2pic == 3 then if Up then local partclone3 = game.Lighting.PartOfMap:Clone() wait() partclone3.Part.Anchored = true partclone3.Part.Size = Vector3.new(15.86, math.random(0.05,3), 19.21) partclone3.Parent = workspace.Map partclone3.Part.Position = script.Parent.Position + Vector3.new(0,0,19.095) Up:Destroy() partclone3.Part.Folder.Down:Destroy() elseif side2pic == 4 then if Down then local partclone4 = game.Lighting.PartOfMap:Clone() wait() partclone4.Part.Anchored = true partclone4.Part.Size = Vector3.new(15.86, math.random(0.05,3), 19.21) partclone4.Parent = workspace.Map partclone4.Part.Position = script.Parent.Position + Vector3.new(0,0,-19.095) Down:Destroy() partclone4.Part.Folder.Up:Destroy() else script.Disabled = true end end end end end end end
it only spawns parts that go left, and doesn't spawn in other directions
I'm not going to dignify this with a proper analysis for areas you can improve, which there are a lot of.
You're only generating Left pieces because you aren't end
ing the if Left then
, if Down then
, if Right then
, or if Up then
statements before starting the elseif side2pic = ...
statements.
Basically, your ends don't line up. This would be a lot more obvious if you indented your code properly.