How to make a board game moving system

I want to be able to make a game that requires you moving on a grid based area of blocks. However, I have searched many places and have not seen any answers. I want to figure out how to make it so your player can move like a board game piece. Here’s a quick example sketch I drew up. Thanks!


I know, but do you know any places where I can learn? :unamused: Or find an answer? Because if you don’t want to answer, then don’t.

1 Like

search in

Doesn’t narrow things down at all, but thanks.

1 Like

make a part for each board tile
then teleport the thing on top of it

(this dude’s being unhelpful)

The best way to do this is to create a 2D array that maps each position on the board, then for each position, state if an object is in that grid. It makes math surprisingly easy if you know which order your 2D array is in, I like to do [y][x]

For example, here’s a 2D array for a 3x3 grid

local board = {

local character =
character:MoveTo(1, 2)
--internally this does
function MoveTo(X, Y)
  if self.X and self.Y then
    board[self.Y][self.X] = nil

  self.X = X
  self.Y = Y
  board[Y][X] = self

Generally, each character would hold their own state which maps where they are, it makes this a hella of a lot easier to implement

This is probably way out there but its how i’d implement it.


i think you need a tool for the player to move things

Thank you for being actually helpful! I will look at this and try it out.

Hey quick question, @metatablecatmaid!

What is the supposed to do?

Basing a slight reference off of your code, I pulled off a quick working prototype:

My code:

local grid = {} -- the grid

-- some variables
local gridSize =, 11)
local cellSize =, 4)

-- fill the grid
for y = 1, gridSize.Y do
	-- set grid[Y cordinate]
	grid[y] = {}
	for x = 1, gridSize.X do
		-- set grid[y][X cordinate]
		grid[y][x] =, y)
		-- to visualize the grid
		local part ="Part")
		part.Anchored = true
		part.Size =, 1, cellSize.Y)
		part.Position = * x, -0.5, cellSize.Y * y)
		part.Color = x % 2 == 0 and y % 2 == 0 and, 0.85, 0.85) or, 0.5, 0.5)
		part.Parent = workspace.GridVisual

-- function that handles
local function movePartToGrid(part, position)
	local fetchedPosition = grid[position.Y][position.X]
	part.Position = * cellSize.X, part.Size.Y / 2, fetchedPosition.Y * cellSize.Y)

local part = workspace.Indicator -- the red part in workspace
while true do
	local randX = math.random(gridSize.X) -- generate a random x cordinate to move the part to
	local randY = math.random(gridSize.Y) -- same with y cordinate
	movePartToGrid(part,, randY)) -- finally move it

Edit: Place file - Grid MoveTo System.rbxl (23.1 KB)

1 Like

I would personally keep the rectangles inside an array with the index being their number on the board since its more convenient for a board game, for example a 8x8 grid would have rectangles numbered 0-63

Here’s some example code just place it inside a frame it should scale accordingly:

local ParentFrame = script.Parent

local xGridsize, yGridsize = 8,8

local GridArray = {}

-- Calculate the absolute rectangle size to keep the grid scaled
local xframeSize, yframeSize = ParentFrame.AbsoluteSize.X/xGridsize, ParentFrame.AbsoluteSize.Y/yGridsize

-- just to visualize
local function show_rect_number(rectNumber, parent)
	local newtext ="TextLabel")
	newtext.AnchorPoint =,0.5)
	newtext.Position = UDim2.fromScale(0.5,0.5)
	newtext.Size = UDim2.fromScale(1,1)
	newtext.Text = rectNumber
	newtext.Parent = parent

for x = 0, xGridsize-1, 1 do
	for y = 0, yGridsize-1, 1 do
		local rectNumber = (y + x*yGridsize)
		local newFrame ="Frame")
		newFrame.Size = UDim2.fromOffset(xframeSize,yframeSize)
		newFrame.Position = UDim2.fromOffset(x * xframeSize, y * yframeSize)
		newFrame.Parent = ParentFrame
		GridArray[rectNumber] = newFrame
		show_rect_number(rectNumber, newFrame)

function move_on_grid(player, position)
	local frameToMoveTo = GridArray[position]
	player.Position = UDim2.fromOffset(frameToMoveTo.Position.X.Offset + (frameToMoveTo.Size.X.Offset/2), frameToMoveTo.Position.Y.Offset + (frameToMoveTo.Size.Y.Offset/2))

local playerFrame ="Frame")
playerFrame.BackgroundColor3 =, 0, 0.498039)
playerFrame.Size = UDim2.fromOffset(10,10)
playerFrame.AnchorPoint =,0.5)
playerFrame.Name = "player"
playerFrame.ZIndex = 5
playerFrame.Parent = ParentFrame

-- move the player to a rectangle on the grid
move_on_grid(playerFrame, 60)
1 Like

The simplest way would be to just have a 2d array of sorts. Or really it can be considered a vector2.

Board[Y][X] = ""

Ideally, you would want to set the state of each piece as well as the board tile.

local Piece = {
Position =,2)

local Tiles = {
[1][2] = {
State = "Full";