I'm making a game. What is the most effective way to get a tile to affect ones around it?

Hello developers!

I’m new to scripting with Lua in Roblox and I’m trying to make a game based off of the Roblox DevHub’s basic coding course “scoring points” tutorial.

The game is one where you try to survive on a series of platforms which disappear beneath your feet as you touch them. I’ve gotten this game mechanic to work just fine, however I want to add a bit of gameplay variety by adding special platforms which do other things that just disappear.

One of these special platforms would affect the platforms around it in a sort of plus pattern, like this:

(Red platform would be the platform touched, yellow would be the tiles disappeared due to this, and the black would remain unaffected)

Any ideas on how to do this?

1 Like

Sorry, what does that mean? Did you make a post?

I would make it check if the tiles around it either share the x or z value in the position. Doing that would only affect tiles in a + like pattern.

Example:

function GetPlusPatternTiles(MainTile)
   local Affected = {}
   for _, Tile in pairs(game.Workspace.Tiles:GetChildren() do
      if Tile.Position.X == MainTile.Position.X or Tile.Position.Z == MainTile.Position.Z then
         table.insert(Affected, Tile)
         Tile.BrickColor = "New Yeller"
      end
   end
   return Affected
end

print(GetPlusPatternTiles(game.Workspace.Tiles.Tile))

That should return you the Tiles in question.

2 Likes