I'm trying to make a minesweeper game, but I'm having trouble with adding 1 to each not-bomb tile for every bomb tile it touches. Here's my code
local position = Vector3.new(0,0,0)
local blockCount = 25
local blockCounting = 0
local totalFlags = 100
local currentFlags = 0
for i = 1, blockCount, 1 do
for e = 1, blockCount, 1 do
blockCounting += 1
print("ran")
local block = game.ServerStorage.BlockClone:Clone()
block.Name = block.Name .. blockCounting
block.Position = position
block.Parent = workspace.Blocks
local flagInt = block:WaitForChild("FlagCount")
local click = block:WaitForChild("Click")
if (e + i) % 2 == 0 then
block.BrickColor = BrickColor.new("Slime green")
else
block.BrickColor = BrickColor.new("Sand green")
end
if currentFlags < totalFlags then
end
position += Vector3.new(5,0,0)
end
position += Vector3.new(-5*blockCount,0,-5)
end
local tileList = {}
for i, tilePart in ipairs(workspace.Blocks:GetChildren()) do
table.insert(tileList, tilePart.Name)
end
for i = 1, 100, 1 do
local flagTile = math.random(1, #tileList)
local block = workspace.Blocks:FindFirstChild(tileList[flagTile])
local flagInt = block:WaitForChild("FlagCount")
flagInt.Value = -1
block.BrickColor = BrickColor.new('Really red')
currentFlags += 1
print(currentFlags)
table.remove(tileList, flagTile)
end