Saving system switches values of both stats to equal?
Asked by
4 years ago Edited 4 years ago
01 | local dataStore = game:GetService( "DataStoreService" ):GetDataStore( "DiceomathyData" ) |
02 | local datst = game:GetService( "DataStoreService" ):GetDataStore( "DiceomathyDataPoint" ) |
08 | game.Players.PlayerAdded:Connect( function (plr) |
10 | local leaderstats = Instance.new( "Folder" ) |
11 | leaderstats.Name = "leaderstats" |
12 | leaderstats.Parent = plr |
14 | local points = Instance.new( "IntValue" ) |
15 | points.Name = "Points" |
16 | points.Value = dataStore:GetAsync(plr.UserId) or starterPoints |
17 | points.Parent = leaderstats |
19 | local rolls = Instance.new( "IntValue" ) |
21 | rolls.Value = dataStore:GetAsync(plr.UserId) or starterRolls |
22 | rolls.Parent = leaderstats |
25 | game.Players.PlayerRemoving:Connect( function (plr) |
27 | dataStore:SetAsync(plr.UserId, plr.leaderstats.Rolls.Value) |
31 | game.Players.PlayerRemoving:Connect( function (plr) |
32 | datst:SetAsync(plr.UserId, plr.leaderstats.Points.Value) |
My script seems to be saving the data, but... not properly. When I add the points to let's say, 123, and rolls to 0. Then when I come back the points is now 0 and rolls is 0. I tried again with different values. 100 for points, 10 for rolls, when I rejoined my game, both values were 100. I would like a person out there to figure out how to get both values separately saved.