# How to create a cash stacking system!

1. What do you want to achieve?
I want to achieve a cash stacking system

2. What is the issue?
I want to create a cash stacking system like this
robloxapp-20231015-2149160.wmv (5.3 MB)

3. What solutions have you tried so far?
I searched all over the Devforum

One person did say

You just gotta divide the cash by the amount of cash that it takes to make one layer, use the remainder to calculate how many smaller stacks are on top, until you’ve used all of it.” – It would have been helpful if the user provided an example.

Video of what i want to achieve
robloxapp-20231015-2149160.wmv (5.3 MB)

can u like provide a bit more explanation of what u want to achieve? (like i mean i know its a cash stacking system, but in which case u want to use this)

1 Like

Lets say that 100 bucks is one cash instance, 12 of them would fill up a layer, so just do something like this:

``````local layers = 0
local rows = 4 -- 4 rows of cash available in the stack
local maxStack = 12
local divider = 100 -- how much cash is 1 instance

local startPos = cashStackStartingPosition
local nextLayerPos = nextLayerFirstStackPosition
local nextRowPos = nextRowFirstStackPosition
-- substitute these 3 values with the positions in your stack

local function StackControl(earnedCash) -- call it when you want to update the stack
local amount = math.round(earnedCash / divider)
local prev -- prev is gonna be set to the previous instance in the loop to calculate the position of the next one

for i = 1, amount do
local newPos
if i % maxStack then -- if the layer is full
-- go to the first slot of the next layer
newPos = nextLayerPos
elseif i % rows then -- if the row is full
-- go to the first slot of the next row
newPos = nextRowPos
else
if i == 1 then
newPos = startPos.Position
else
newPos = prev.Position  + Vector3.new(3,0,0) -- add the offset of the new model
end
end

local part = CashModel:Clone()

part.Position = newPos
part.Parent = workspace

prev  = part
end
end
``````

I’ll try this and tell you if it works