Basically im trying to make a simple maze where there are walls lined up in rows and randomly 10 of the 27 will be seen. This is my script right now.
local Parts = workspace.Maze:GetChildren() for i, v in pairs(Parts) do math.randomseed(tick()) local RandomPart = Parts[math.random(1,#Parts)]
function invisible() RandomPart.Transparency = 0 RandomPart.CanCollide = true end invisible()
end
So how would I make this for loop work. Thanks!
table.remove()
could help. this is because it will remove the wall from the list of walls and return it, so you do not change the same wall twice.
local N_VISIBLE = 10 local walls = workspace.Maze:GetChildren() for _ = 1, N_VISIBLE do local wall = table.remove(walls, math.random(#walls)) wall.Transparency = 0 wall.CanCollide = true end
using a loop that runs N_VISIBLE times, which is 10, it gets and removes a random wall from the list. then it makes it visible and whatever.