Basically, I am trying to keep track of every Node on the server
I made a big DB that keeps track of every Node (an Basepart) with a respective NodeID
What I tried:
local NodeDatabase = {} --Current used Nodes
function NodeHandler:new() --DO NOT FORGET: Node is a table
--Node Template
local Node = setmetatable({
NodeID = tonumber(#NodeDatabase + 1), --ID gets set to the last index of the table + 1 (so ID is the same as the Node index in the DB)
NodeRarity = nil,
NodeDurability = nil,
NodePosition = nil
}, self)
table.insert(NodeDatabase, Node)
return Node
end
As you can see here, I tried to make an ID system in which the ID will correspond to the index of the Node in the DB (i.e ID = index in the DB)
I was going to make an attribute and set the ID to NodeID, so I associate the Node in the DB to the Node in workspace
ISSUE:
I soon realized that not only its going to be terrible for performance bc everytime I will destroy/add a node, I will have to update every single node in the DB using a for loop, but it can cause other issues like DB data corruption (if two methods run at once, etc.)
Do yall suggestions on how I can track each unique workspace Nodes on the server or any way to assign a unique ID to each Node without having to update every single change on DB
Thank you