local dataTemplate = {
['Cash'] = 0;
['Points'] = 0;
['Rank'] = 'Advanced';
['Unique Items'] = {};
}
game.Players.PlayerAdded:Connect(function(plr)
local ds = game:GetService('DataStoreService')
local dataDS = ds:GetDataStore('datads1')
local dk = plr.UserId
dataDS:SetAsync(dk,dataTemplate)
end)
Say I have a table with player data in it for example, would i have to add a unique playerID into the table and then put the data table into it or would it work fine just using getasync and setasync to set the players table values.
Just curious since its a server script if there would be issues with data not pertaining to the individual or tables getting mixed if a request is made at the same time?
(the code linked is just an example, obviously not my actual code)
Not at all, when you make the SetAsync request as long as you provide the data key you are all good nothing will get mixed up with other keys due to large amounts of requests so you should be good.
so i dont have to insert a special table/dictionary for every user that has data? i can use 1 table in the script and just call it for every user with unique data in it for each?
You can definitely use a template dataset and set that for each player but when the player has data (Like more cash or smth) then obviously 2 tables will be different.