01 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "mnaj22 level" ) |
02 |
03 |
04 | game.Players.PlayerAdded:connect( function (player) |
05 | wait() |
06 |
07 | Level = player.PlayerGui.ScreenGui.Value |
08 |
09 | local key = "player-" ..player.userId |
10 |
11 | local savedValues = DataStore:GetAsync(key) |
12 |
13 | if savedValues then |
14 | Level.value = savedValues( 1 ) |
15 | else |
16 | local valuesToSave = (Level) |
17 | DataStore:SetAsync(key, valuesToSave) |
18 | end |
19 | end ) |
I'm not well-versed with data stores as yet, so I know I'm not the most qualified to answer this question -- but no one else is doing so. From looking at it (and checking the wiki a bit), it doesn't look as if your problem is in using the storage itself, but that you're setting your 'Level.value' to 'savedValues(1)' rather than just 'savedValues'. Not sure if I'm just misreading it.
01 | local DataStore = game:GetService( "DataStoreService" ):GetDataStore( "mnaj22 level" ) |
02 |
03 |
04 | game.Players.PlayerAdded:connect( function (player) |
05 | wait() |
06 |
07 | Level = player.PlayerGui.ScreenGui.Value |
08 |
09 | local key = "player-" ..player.userId |
10 |
11 | local savedValues = DataStore:GetAsync(key) |
12 |
13 | if savedValues then |
14 | Level.Value = savedValues [ 1 ] |
15 | else |
16 | local valuesToSave = Level |
17 | DataStore:SetAsync(key, valuesToSave) |
18 | end |
19 | end ) |
Few syntax mistakes. When you want to access a member of a table, use square brackets [] not parentheses ().