Title says it all. I am a little confused on why dataStores do not save mixed arrays / dictionaries. Could someone explain to me?
local _DATASTORE_SEVER = game:GetService("DataStoreService"):GetDataStore("____SEERRRVVVEEREEEERR_DDDAAAATTTTAAAAAAA_______")
local DAATA = {
Test = {6,8,9,0,
yes99=false}, --MIXED ARRAY
}
local data = _DATASTORE_SEVER:GetAsync("TEST")
if data == nil then
local Save__DATA, _message = pcall(function()
_DATASTORE_SEVER:SetAsync("TEST", DAATA)
end)
if Save__DATA == true then
print("Saved ")
else
warn(_message)
end
else
print(data)
end
Everything above works fine. However, the data that is loaded is altered for some reason. ‘yess99’ is left out when loading data. Which is why I am wondering what could be the issue.
The indices can be numerical (don’t start from 1), just the table must take the form of a dictionary.
--SERVER
local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.RemoteEvent
players.PlayerAdded:Connect(function(player)
task.wait(1)
remote:FireClient(player, {[5] = true, [6] = true, ["a"] = true})
end)
--LOCAL
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")
remote.OnClientEvent:Connect(function(data)
for index, value in pairs(data) do
print(index, value)
end
end)
As you stated this behavior is also present for RemoteEvents/RemoteFunctions, in addition to this, it is also present for BindableEvents/BindableFunctions, as the following code snippet will exemplify.
local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local bindable = replicated.Event
bindable.Event:Connect(function(data)
for index, value in pairs(data) do
print(index, value)
end
end)
bindable:Fire({true, false, ["a"] = true})