Using DataStore
I'm trying to figure out how I can save and update a "key" in the datastore with a table. I've never used DataStore before so I'm trying to figure out how it works.
I have{plr.Name, servername, password, public};
and I want to save that to the next position in the serverList table.
01 | serverData = game:GetService( "DataStoreService" ):GetDataStore( "ds" ) |
03 | if serverData:GetAsync( "Servers" ) then |
04 | serverData:SetAsync( "servers" , serverData:GetAsync( "servers" )) |
06 | serverData:SetAsync( "servers" , serverList) |
10 | function Workspace.createServer.OnServerInvoke(plr, servername, password, password 2 ) |
13 | if password 2 ~ = "" then |
14 | print (plr.Name.. " wishes to create a server called " ..servername.. " with the password " ..password) |
17 | print (plr.Name.. " wishes to create a server called " ..servername.. " without a password" ) |
20 | table.insert(serverList, #serverList+ 1 , { plr.Name, servername, password, public } ) |
21 | serverData:UpdateAsync( "servers" , function (serverList) return serverList [ #serverList ] end ) |