I have a DataStore script. I save everything through a table, and use a number(called a MIndex in my script) to save the position of each value in the table. The table data does not save MIndex’es above 10 correctly. It is only these positions that are problematic, and not with any method or consistency.
An image of the explorer setup with data(the MIndex of the values in the “Weapons” folder correspond with the name of the value):
My Code:
local dss = game:GetService("DataStoreService")
local master = dss:GetDataStore("Data")
game.Players.PlayerAdded:Connect(function(plr)
local folder = script.Stats:Clone()
folder.Parent = plr
local data = master:GetAsync(plr.UserId)
if data ~= nil then
for _, val in pairs(folder:GetDescendants()) do
if val:IsA("StringValue") or val:IsA("BoolValue") or val:IsA("IntValue") and val.Name ~= "MIndex" then
if data[val.MIndex.Value] ~= nil then
val.Value = data[val.MIndex.Value]
end
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = {}
for _, val in pairs(plr.Stats:GetDescendants()) do
if val:IsA("StringValue") or val:IsA("BoolValue") or val:IsA("IntValue") and val.Name ~= "MIndex" then
table.insert(data, val.MIndex.Value, val.Value)
end
end
master:SetAsync(plr.UserId, data)
end)
Feel free to ask for any details that I didn’t specify in this post, as I may have overlooked some things. Thank you to any and all who can help.
Edit: I did some printing, and realized that the DataStores are saving correctly. Somehow my code is misinterpreting it into the Stats folder.
Edit2: The MInex’es above 10 are probably erroring because of the Coins, Equipped, and Health in positions 11, 12, and 13.
