Creating Loadout Grid

Hello, I’m making a grid system. It’s 5x5. I have parts and I want it to spawn on each unit of the 5x5. I have positions that go 1-25. How can I turn those positions into positions on the grid? Ex: How can I make 17, turn into 2 down and 1 right?

Image:

Script:

local clone = part:Clone()
clone.Position = Vector3.new(Vector3.new(pos - (math.ceil(pos/5)*5) * 8, 1, math.ceil(pos / 5) * 8), 1, math.ceil(pos / 5) * 8)
clone.Parent = workspace

This script doesn’t work btw.

Thank you.

1 Like

i’m not sure what you mean by “17 turning into 2 down and 1 right” since that would just go off the grid
and 2 down and 1 right from 1 doesn’t even reach 17

Sorry I meant from 1. Like 2 squares down and 1 square right.
Latest Script:

Vector3.new(math.abs(pos - (math.ceil(pos/5)*5)) * 8, 1, math.abs(pos - (math.ceil(pos/5)*5)) * 8)

Sadly this did not work. Instead of a square, it created a diagonal line. Thank you though.

Latest Script:

Vector3.new(pos - (math.floor(pos/5)*5), 1, (pos - math.floor(pos/5)*5)) * Vector3.new(8, 1, 8)

I found a solution!
Final Script:

local xPos = ((math.ceil(pos/5) * 5) - pos)
local zPos = ((math.ceil(pos/5) * 5)/5)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.