This is the format I'm using for the dictionary to SetAsync()
local PlayerData = {
["Models"] = {
};
["Resources"] = {
["Money"] = 1; -- I want to update one of these
["Population"] = 12;
["Wood"] = 24;
["Stone"] = 64;
["Electric"] = 14;
["Water"] = 163;
}
}
This is the script I wrote to tell the server that the player's Data was changed
local Event = game.ReplicatedStorage.remoteevents.SaveData
wait()
for i, resource in pairs(game.Players.LocalPlayer:WaitForChild("Resources"):GetChildren()) do
resource:GetPropertyChangedSignal("Value"):Connect(function()
Event:FireServer(resource, resource.Value)
end)
end
Corresponding remote event script:
game.ReplicatedStorage.remoteevents.SaveData.OnServerEvent:Connect(function(player, resource, value)
player.Resources[resource.Name].Value = value
DataStore.UpdateResource(player, resource.Name, value) -- this is my own function inside of a modulescript
end)
Lastly, here is my ModuleScript function:
function DataStore.UpdateResource(Player, Resource, Value)
local DataStoreService = game:GetService("DataStoreService")
local Data = DataStoreService:GetDataStore("PlayerData"):GetAsync("Player_" .. Player.UserId)
DataStoreService:GetDataStore("PlayerData"):SetAsync(("Player_" .. Player.UserId)["Resources"][Resource], Value) -- Everything works fine up until here
end
error:
15:05:37.513 - ServerScriptService.SaveDict.SaveData:15: attempt to index field 'Resources' (a nil value)
How do I access a single key inside of the dictionary "Resources" Which is inside of the dictionary "Player_26246132"?
any help is greatly appreciated!

6 comments
Worst security ever. Someone could just go fire the remote event and get rich.
y dis site no support emojis D:
that's what i was thinking.I'll have to change it later. My problem stands though.
Can you say what exact script the error is occurring on? None of those snippets of code have 15 lines so there is no way to tell which one is the problem.
The ModuleScript function (last snippet of code), the line that I commented on
"Player_Player.UserId"["Resources"] does not work. You are trying to treat a string like a dictionary.