Why my second value from leaderstats is not saving?
I want to save 2 int values, the first one is saving, everything is fine but when i try to save the second one is not saving at all.
I looked on google for a fix, i modified the whole script as i found online and is still not working
Here is the code:
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local KingPointsStore = DataStoreService:GetDataStore( "KingPointsStore" ) |
03 | local tutorialStore = DataStoreService:GetDataStore( 'tutorialStore' ) |
05 | game.Players.PlayerAdded:Connect( function (player) |
07 | local leaderstats = Instance.new( "Folder" ) |
08 | leaderstats.Name = "Stats" |
09 | leaderstats.Parent = player |
11 | local King = Instance.new( "IntValue" ) |
12 | King.Name = "KingPoints" |
13 | King.Parent = leaderstats |
15 | local tutorial = Instance.new( 'IntValue' ) |
16 | tutorial.Name = 'Tutorial' |
17 | tutorial.Parent = leaderstats |
21 | local UserId = player.UserId |
26 | local success, errormessage = pcall ( function () |
27 | kingData = KingPointsStore:GetAsync(UserId) |
28 | tutorialData = tutorialStore:GetAsync(UserId) |
33 | tutorial.Value = tutorialData |
39 | game.Players.PlayerRemoving:Connect( function (player) |
40 | local UserId = player.UserId |
41 | local kingData = player.Stats.KingPoints.Value |
42 | local tutorialData = player.Stats.Tutorial.Value |
44 | KingPointsStore:SetAsync(UserId, kingData) |
45 | tutorialStore:SetAsync(UserId, tutorialData) |