I have a game where there is a random path on tiles how would I make that


those are what the tiles look like but my issue is that how would I make them so the tiles have a path that isn’t impossible for the player to reach or makes sense?

Not sure by what you mean in the post but I’m assuming you mean how can you make the tiles randomly make it impossible for players to jump on? (or just disappear)

no so It makes a random path and some tiles will fall if its not the right one and it needs to make a path that isnt everywhere it needs to be a line that the player could walk on like this


just make a random path that the player can walk on

Create a for loop for all the tiles and grab the distance between each random part you grab and if it’s close then tween the part to fall when player touches it.

I think a multi-dimensional array would be more performant.

I only really know how to do that in C# however both are performant enough since you’re grabbing only few random parts and grabbing the distance, not entirely a performant issue however yes that would be a lot better to do since it would most def be more accurate.

local randomObject = Random.new(tick())

local rows = {}

for i1 = 1, 8 do
	for i2 = 1, 4 do
		local row = {}
		table.insert(row, {})
		if i2 == 4 then
			table.insert(rows, row)
		end
	end
end

local function createRandomPath()
	local path = {}
	local last = randomObject:NextInteger(1, 4)
	for _, row in ipairs(rows) do
		local node
		repeat
			node = randomObject:NextInteger(1, 4)
		until node - 1 == last or node == last or node + 1 == last
		table.insert(path, node)
		last = node
	end
	return path
end

for i = 1, 10 do
	local randomPath = createRandomPath()
	print(table.concat(randomPath, " "))
end

Here’s a sample of 10 results.

image

This is probably not be the best way to do this but here is what I would do;

local colOne = math.Random(1, 4) --colOne is the first collum, while 1, 2, 3, and 4 are your blocks in that colum.  Group all of the blocks in each colum together and call the model colOne. (for each) and name each of the blocks inside "1", "2", "3", "4"
local colTwo = math.Random(1, 4)
local colThree = math.Random(1, 4)
local colFour = math.Random(1, 4)
local colFive = math.Random(1, 4)
local colSix = math.Random(1, 4)
local colSeven = math.Random(1, 4)
local colEight = math.Random(1, 4)
local colNine = math.Random(1, 4)

local roundSecs = 120

while wait(1) do
     roundSecs -= 1
     
     if not roundSecs == 0 then
          roundSecs = 120
          
          --Set all the parts to CanColide = false right here 
          
          colOne = math.Random(1, 4) -- Re-randomizes after each round
          colTwo = math.Random(1, 4)
          colThree = math.Random(1, 4)
          colFour = math.Random(1, 4)
          colFive = math.Random(1, 4)
          colSix = math.Random(1, 4)
          colSeven = math.Random(1, 4)
          colEight = math.Random(1, 4)
          colNine = math.Random(1, 4)
          
          game.workspace.colOne:FindFirstChild(colOne).CanCollide = true
          game.workspace.colTwo:FindFirstChild(colTwo).CanCollide = true          
          game.workspace.colThree:FindFirstChild(colThree).CanCollide = true
          game.workspace.colFour:FindFirstChild(colFour).CanCollide = true
          game.workspace.colFive:FindFirstChild(colFive).CanCollide = true
          game.workspace.colSix:FindFirstChild(colSix).CanCollide = true
          game.workspace.colSeven:FindFirstChild(colSeven).CanCollide = true
          game.workspace.colEight:FindFirstChild(colEight).CanCollide = true
          game.workspace.colNine:FindFirstChild(colNine).CanCollide = true
     end
end)

Sorry if anything is misspelled, I wrote this right here.

I think that would work but it would add another level of complexity that I don’t want deal with right now I think there would be easier solutions.

il look into using that thanks!