RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a randomly generating maze"
-- Server script local Maze = require(script.Maze) -- assuming you have a Maze module local mazeWidth = 10 local mazeHeight = 10 local maze = Maze.new(mazeWidth, mazeHeight) maze:Generate() for x = 1, mazeWidth do for y = 1, mazeHeight do local cell = maze:GetCell(x, y) local part = Instance.new("Part") part.Anchored = true part.Size = Vector3.new(1, 1, 1) part.Position = Vector3.new(x * 2, 0, y * 2) part.Parent = game.Workspace if cell.walls[Maze.Directions.North] then local wall = Instance.new("Part") wall.Anchored = true wall.Size = Vector3.new(1, 1, 0.1) wall.Position = part.Position + Vector3.new(0, 0, 1) wall.Parent = game.Workspace end if cell.walls[Maze.Directions.East] then local wall = Instance.new("Part") wall.Anchored = true wall.Size = Vector3.new(0.1, 1, 1) wall.Position = part.Position + Vector3.new(1, 0, 0) wall.Parent = game.Workspace end if cell.walls[Maze.Directions.South] then local wall = Instance.new("Part") wall.Anchored = true wall.Size = Vector3.new(1, 1, 0.1) wall.Position = part.Position - Vector3.new(0, 0, 1) wall.Parent = game.Workspace end if cell.walls[Maze.Directions.West] then local wall = Instance.new("Part") wall.Anchored = true wall.Size = Vector3.new(0.1, 1, 1) wall.Position = part.Position - Vector3.new(1, 0, 0) wall.Parent = game.Workspace end end end -- This script requires a Maze module which is not provided. It generates a maze by creating parts for each cell and its walls. The maze's width and height can be adjusted by changing the mazeWidth and mazeHeight variables.