- What do you want to achieve?
So, I have no idea how to even properly describe what I am wanting to do but I will try my best!
(I APOLOGISE IN ADVANCE)
I am essentially trying to make a datastore system that does the following in order:
-Initial check if there is existing playerData
-If there is existing data, validates it using a defaultData table.
-If there is missing data (game updated, new variables needed to datastore) update it!
-If there is unused data (not in defaultData), delete it!
- What is the issue? Include screenshots / videos if possible!
Now the problem does not lie within the DataStore part, it’s just trying to actually validate the data. I have no idea how I would do this efficiently as the current method I made doesn’t seem to work. (see below)
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have made a very basic method to perform this using for loops and basically counting the checked variables. See here:
local defaultData = {
banned = false,
banLength = 0,
banReason = "empty"
}
local checkTable = {
banned = false,
banLength = 0,
banReason = "empty",
testData = "LMAO"
}
count = 0
for i, v in pairs(checkTable) do
if defaultData[i] then
count = count + 1
else
print("The "..i.." variable does not match! ")
end
end
print(count)
This is what it ends up printing:
What I intended this to print was the testData and the count value be 3, however for whatever reason it decides to ALSO print the banned variable leaving the count variable at 2. Does anyone know why this is happening? If you could suggest a more efficient method to perform this or a fix for this method that would be AMAZING!