Saving String Values in Data Store?
Hello,
I was trying to save 2 string values parented inside of the player, But I have some issues:
- the first String Value is called "desk1"
-the second String Value is called "desk2"
so when I get into the game, If desk1.Value and desk2.Value is changed it shows that It got saved but when I rejoin, it still the same.
Script:
01 | local DS = game:GetService( "DataStoreService" ):GetDataStore( "rubyigergetgseddendikzakinchepes" ) |
02 | game.Players.PlayerAdded:Connect( function (plr) |
04 | local plrkey = "id_" ..plr.userId |
06 | local savevalue 1 = plr.leaderstats.Money |
07 | local savevalue 2 = plr.workspaces 0 |
08 | local savevalue 3 = plr.desk 1 |
09 | local savevalue 4 = plr.desk 2 |
11 | local GetSaved = DS:GetAsync(plrkey) |
15 | savevalue 1. Value = GetSaved [ 1 ] or 10000 |
16 | savevalue 2. Value = GetSaved [ 2 ] or 0 |
17 | savevalue 4. Value = GetSaved [ 5 ] or "none" |
19 | savevalue 3. Value = GetSaved [ 3 ] or "none" |
22 | local NumbersForSaving = { savevalue 1. Value or 10000 , savevalue 2. Value,savevalue 4. Value, savevalue 3. Value } |
23 | DS:GetAsync(plrkey, NumbersForSaving) |
26 | savevalue 1. Changed:Connect( function (changed) DS:SetAsync( "id" ..plr.userId, { plr.leaderstats.Money.Value } ) print ( "Changed Money" ) end ) |
27 | savevalue 2. Changed:Connect( function (changed) DS:SetAsync( "id" ..plr.userId, { plr.workspaces 0. Value } ) print ( "Changed workspaces" ) end ) |
28 | savevalue 3. Changed:Connect( function (changed) DS:SetAsync( "id" ..plr.userId, { plr.desk 1. Value } ) print ( "Changed desk1" ) end ) |
29 | savevalue 4. Changed:Connect( function (changed) DS:SetAsync( "id" ..plr.userId, { plr.desk 2. Value } ) print ( "Changed desk2" ) end ) |
32 | game.Players.PlayerRemoving:Connect( function (player) |
34 | DS:SetAsync( "id" ..player.userId, { player.desk 2. Value } ) print ( "saved" ) |
I don't see any errors in the output, But when the values change, They get saved cuz I did does print() inside of the script, So I can see it in the output