How and when should I use Stacks (LIFO)

Simply put I want to be able to know when and how I can use Stacks(LIFO) in a functional way. It seems like a intersting sort of data structure and I actually want to have good use of it.

Stacks documentation : Stacks (roblox.com)

If you’re to lazy to check out the documentation then here’s a example from the docs:

-- OOP boilerplate - create a class, add __index, then make a constructor
Stack = {}
Stack.__index = Stack
function Stack.new() return setmetatable({}, Stack) end
 
-- put a new object onto a stack
function Stack:push(input)
	self[#self+1] = input
end
-- take an object off a stack
function Stack:pop()
	assert(#self > 0, "Stack underflow")
	local output = self[#self]
	self[#self] = nil
	return output
end

This is coming from someone who has never heard of this data type structure of stacks before, but I don’t think this would be useful inside of any roblox game and would be better to use a normal array or dictionary structure.

They are usually used for undo functions in software.