I am trying to make a sort of “corruption” with the tiles (it slowly takes more and more tiles and expands). I tried making it so that after a certain amount of times it corrupts more & more tiles, something similar to how I have tried to show in this image.
The only problem is that instead it takes like chunks instead of following a square pattern & I wanted to know what was my problem here’s the code.
local TilesBanned = {"TallTile","TallERTile"}
local function tileChoose()
local tilesF = workspace.Tiles:GetChildren()
local rndTile = tilesF[math.random(1,#tilesF)]
local tile = rndTile
if table.find(TilesBanned,tile.TileName.Value) then
return tileChoose()
else
return tile
end
end
local chosenTile = tileChoose()
chosenTile.PrimaryPart.Material = Enum.Material.Plastic
chosenTile.PrimaryPart.MaterialVariant = "Fleshling2"
chosenTile.PrimaryPart.Color = Color3.fromRGB(255,255,255)
local bool = Instance.new("BoolValue")
bool.Parent = chosenTile
bool.Name = "Slower"
local FarEnd = Instance.new("ObjectValue")
FarEnd.Name = "FarEnd"
FarEnd.Parent = chosenTile
FarEnd.Value = Screeching
local Timer = 4
local Range = 0 -- change goes up when more tiles corrupt
local BannedTilesToNotCorrupt = {}
table.insert(BannedTilesToNotCorrupt,chosenTile)
local SizeCorruption = 0
local Corruption = 0
while task.wait(Timer) do
Corruption += 9
for i, y in pairs(workspace.Tiles:GetChildren()) do
if y:FindFirstChild("FarEnd") and y:IsA("Model") then
if y:FindFirstChild("FarEnd").Value == Screeching then
if SizeCorruption <= Corruption then
SizeCorruption += .5
table.insert(BannedTilesToNotCorrupt,y)
y:FindFirstChild("FarEnd"):Destroy()
local function getAllAroundParts(part)
local function FindTile(bool,tileIs)
if workspace.Tiles:GetChildren() == nil then
return
end
local Row = tileIs.Row
local Collum = tileIs.Collum
if bool == "+" then
for i, v in pairs(workspace.Tiles:GetChildren()) do
if v:IsA("Model") then
if v.Row.Value == Row.Value + 1 and v.Collum.Value == Collum.Value then
return v
end
end
end
else
for i, v in pairs(workspace.Tiles:GetChildren()) do
if v:IsA("Model") then
if v.Row.Value == Row.Value - 1 and v.Collum.Value == Collum.Value then
return v
end
end
end
end
end
local TableOfTiles = {}
local getTile1 = workspace.Tiles:FindFirstChild(tostring(tonumber(part.Name)+1))
local getTile2 = workspace.Tiles:FindFirstChild(tostring(tonumber(part.Name)-1))
local rowL1 = FindTile("+",part)
local rowR1 = FindTile("-",part)
if getTile1 then
local rowL2 = FindTile("+",getTile1)
local rowR2 = FindTile("-",getTile1)
if rowL2 ~= nil then
table.insert(TableOfTiles,rowL2)
end
if rowR2 ~= nil then
table.insert(TableOfTiles,rowR2)
end
table.insert(TableOfTiles,getTile1)
end
if getTile2 then
local rowL3 = FindTile("+",getTile2)
local rowR3 = FindTile("-",getTile2)
if rowL3 ~= nil then
table.insert(TableOfTiles,rowL3)
end
if rowR3 ~= nil then
table.insert(TableOfTiles,rowR3)
end
table.insert(TableOfTiles,getTile2)
end
table.insert(TableOfTiles,part)
if rowL1 ~= nil then
table.insert(TableOfTiles,rowL1)
end
if rowR1 ~= nil then
table.insert(TableOfTiles,rowR1)
end
return TableOfTiles
end
local getparts = getAllAroundParts(y)
print(getparts)
for i, v in pairs(getparts) do
if v:IsA("Model") then
if not table.find(BannedTilesToNotCorrupt,v) then
v.PrimaryPart.Material = Enum.Material.Plastic
v.PrimaryPart.MaterialVariant = "Fleshling2"
v.PrimaryPart.Color = Color3.fromRGB(255,255,255)
local bool = Instance.new("BoolValue")
bool.Parent = v
bool.Name = "Slower"
local FarEnd = Instance.new("ObjectValue")
FarEnd.Name = "FarEnd"
FarEnd.Parent = v
FarEnd.Value = Screeching
end
end
end
end
end
end
end
end

