I’m trying to make a system for my DataStores to make sure that a player’s data is fully intact in case I add new keys to the table and new ones need to be created. Right now, I’m having an issue with using table.find()
.
I am trying to search if the key from table ExampleData
exists within the player’s data (referenced as table Data
in the code), and if not it would return nil and warns a message. The problem is, it is always returning nil despite me printing Data
and seeing that the key being checked for exists.
If anyone could explain why this is happening or a correct way to achieve this, please leave a reply.
Here’s the snippet from the code:
for v, i in pairs(ExampleData) do
local Search = (table.find(Data, tostring(v)))
if Search == nil then
warn("Missing data for " .. tostring(v) .. ", generating replacement.")
end
end