RoboCatz.com

Roblox Maze with Tubes

What is Vibe Coding?

Vibe Coding is a cool way to write programs with the help of AI (artificial intelligence). Imagine having a super-smart assistant by your side while coding! The AI can help you in different ways -- it might create an entire program for you, or just give you ideas and help with specific parts, depending on what you need.

To get started, you simply talk to the AI and explain what you want your program to do. The AI will then create a rough version of the program for you. After that, you can ask the AI questions, make suggestions, or request changes to add new features or fix things until the program is just the way you want it.

For this project, you will provide the AI with an existing Maze program and ask it to make improvements such as:
  1. Adding small tokens at various places in the maze to be collected. Include scores shown on a leaderboard.
  2. Adding spherical obstacles placed randomly in the maze to block certain paths.
  3. Use platforms instead of tubes in random places.
  4. Remove the baseplate.
  5. Change the time of day.

Example:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)

local tubeDiameter = 8
local cubeSize = 10

local layerY = {10, 30, 50}
local rowZ   = {-100, -50, 0, 50, 100}
local colX   = {-100, -50, 0, 50, 100}

for yi, y in ipairs(layerY) do
	for zi, z in ipairs(rowZ) do
		for xi, x in ipairs(colX) do

			-- Draw cube
			s.cube({x=x, y=y, z=z, size=cubeSize, color="red", opacity=0.2})
				:cut(s.sphere({x=x, y=y, z=z, size=cubeSize*1.2}))
			-- Draw a disc on the bottom of the first layer of cubes
			if yi == 1 and (z ~= 0 or x ~= 0) then
				s.disc({x=x, y=y-cubeSize/2, z=z, size=cubeSize, color="red", opacity=0.2}):rotateBy(90, 0, 90)
			end

			-- Connect to cube on the right (X direction)
			if colX[xi+1] then
				local x2 = colX[xi+1]
				s.tube({
					x1=x+cubeSize/2, y1=y, z1=z,
					x2=x2-cubeSize/2, y2=y, z2=z,
					size=tubeDiameter, thickness=.5, opacity=0.2
				})
			end

			-- Connect to cube forward (Z direction)
			if rowZ[zi+1] then
				local z2 = rowZ[zi+1]
				s.tube({
					x1=x, y1=y, z1=z+cubeSize/2,
					x2=x, y2=y, z2=z2-cubeSize/2,
					size=tubeDiameter, thickness=.5, opacity=0.2
				}):color("green")
			end

			-- OPTIONAL: Connect vertically (Y direction)
			if layerY[yi+1] then
				local y2 = layerY[yi+1]
				s.tube({
					x1=x, y1=y+cubeSize/2, z1=z,
					x2=x, y2=y2-cubeSize/2, z2=z,
					size=tubeDiameter, thickness=.5, opacity=0.2,
					withLadder=true,
					extraRungs=2
				})
			end

		end
	end
end




I entered a simple prompt and then pasted the code from the example above.

I have a simple maze generating program in Roblox. I would like to add small tokens (cubes with size of 1 or 2) to be collected from random places in the maze (sort of like the game PacMan). I would like a score to be shown (i.e., Leaderboard) that will show the current score. All elements need to be added programatically through the starting script. Here's the maze:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
: : :
: : :

The AI generated a large number of small code fragments (individual functions or loops). I then asked AI to show me the entire code.

Can you show the entire program?
Example:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local s = require(ReplicatedStorage.genericShapes)

------------------------------------------------------------
-- 1. LEADERBOARD (leaderstats)
------------------------------------------------------------
Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local score = Instance.new("IntValue")
    score.Name = "Score"
    score.Value = 0
    score.Parent = leaderstats
end)

------------------------------------------------------------
-- 2. MAZE PARAMETERS
------------------------------------------------------------
local tubeDiameter = 8
local cubeSize = 10

local layerY = {10, 30, 50}
local rowZ   = {-100, -50, 0, 50, 100}
local colX   = {-100, -50, 0, 50, 100}

------------------------------------------------------------
-- 3. BUILD THE MAZE
------------------------------------------------------------
for yi, y in ipairs(layerY) do
    for zi, z in ipairs(rowZ) do
        for xi, x in ipairs(colX) do

            -- Draw cube
            s.cube({x=x, y=y, z=z, size=cubeSize, color="red", opacity=0.2})
                :cut(s.sphere({x=x, y=y, z=z, size=cubeSize*1.2}))

            -- Draw a disc on the bottom of the first layer of cubes
            if yi == 1 and (z ~= 0 or x ~= 0) then
                s.disc({x=x, y=y-cubeSize/2, z=z, size=cubeSize, color="red", opacity=0.2})
                    :rotateBy(90, 0, 90)
            end

            -- Connect to cube on the right (X direction)
            if colX[xi+1] then
                local x2 = colX[xi+1]
                s.tube({
                    x1=x+cubeSize/2, y1=y, z1=z,
                    x2=x2-cubeSize/2, y2=y, z2=z,
                    size=tubeDiameter, thickness=.5, opacity=0.2
                })
            end

            -- Connect to cube forward (Z direction)
            if rowZ[zi+1] then
                local z2 = rowZ[zi+1]
                s.tube({
                    x1=x, y1=y, z1=z+cubeSize/2,
                    x2=x, y2=y, z2=z2-cubeSize/2,
                    size=tubeDiameter, thickness=.5, opacity=0.2
                }):color("green")
            end

            -- OPTIONAL: Connect vertically (Y direction)
            if layerY[yi+1] then
                local y2 = layerY[yi+1]
                s.tube({
                    x1=x, y1=y+cubeSize/2, z1=z,
                    x2=x, y2=y2-cubeSize/2, z2=z,
                    size=tubeDiameter, thickness=.5, opacity=0.2,
                    withLadder=true,
                    extraRungs=2
                })
            end

        end
    end
end

------------------------------------------------------------
-- 4. TOKEN GENERATION
------------------------------------------------------------
local NUM_TOKENS = 25

-- Collect all possible cube centers
local possiblePositions = {}
for _, y in ipairs(layerY) do
    for _, z in ipairs(rowZ) do
        for _, x in ipairs(colX) do
            table.insert(possiblePositions, Vector3.new(x, y, z))
        end
    end
end

-- Shuffle helper
local function shuffle(t)
    for i = #t, 2, -1 do
        local j = math.random(1, i)
        t[i], t[j] = t[j], t[i]
    end
end

shuffle(possiblePositions)

-- Pick the first N positions
local tokenPositions = {}
for i = 1, NUM_TOKENS do
    tokenPositions[i] = possiblePositions[i]
end

------------------------------------------------------------
-- 5. SPAWN TOKENS
------------------------------------------------------------
local tokenFolder = Instance.new("Folder")
tokenFolder.Name = "Tokens"
tokenFolder.Parent = workspace

local function spawnToken(position)
    local token = s.cube({
        x = position.X,
        y = position.Y,
        z = position.Z,
        size = 2,
        color = "yellow",
        opacity = 0.9
    })

    -- Get the underlying part (depends on your genericShapes module)
    local part = token.part or token.model or token
    part.Name = "Token"
    part.CanCollide = false
    part.Anchored = true
    part.Parent = tokenFolder

    return part
end

local tokens = {}
for _, pos in ipairs(tokenPositions) do
    table.insert(tokens, spawnToken(pos))
end

------------------------------------------------------------
-- 6. TOKEN PICKUP LOGIC
------------------------------------------------------------
local function onTokenTouched(token, hit)
    local player = Players:GetPlayerFromCharacter(hit.Parent)
    if not player then return end

    local score = player:FindFirstChild("leaderstats"):FindFirstChild("Score")
    if score then
        score.Value += 1
    end

    token:Destroy()
end

for _, token in ipairs(tokens) do
    token.Touched:Connect(function(hit)
        onTokenTouched(token, hit)
    end)
end

Notice in Section 5, the creation of a "Folder" named: "Tokens" and in the spawnToken() function the creation of parts named: "Token". Please note that these names were not protected from deletion by the plugin scanning script (which deletes unauthorized parts and models) from your world. I had to add these two names to the list of allowed names.

If your AI generates objects, it is possible that the names it gives them will be flagged by the plugin scanning script and automatically deleted. You can ask AI to simply rename those parts something more generic (i.e, Part, Token, Tokens, etc).

If you do not see the Leaderboard stats (i.e., your score), click on the Hamburger menu in the upper left corner of your screen and then select "Leaderboard" to toggle it on/off.