Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why my second value from leaderstats is not saving?

Asked by
MpAlex 16
2 years ago

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:

01local DataStoreService = game:GetService("DataStoreService")
02local KingPointsStore = DataStoreService:GetDataStore("KingPointsStore")
03local tutorialStore = DataStoreService:GetDataStore('tutorialStore')
04 
05game.Players.PlayerAdded:Connect(function(player)
06 
07    local leaderstats = Instance.new("Folder")
08    leaderstats.Name = "Stats"
09    leaderstats.Parent = player
10 
11    local King = Instance.new("IntValue")
12    King.Name = "KingPoints"
13    King.Parent = leaderstats
14 
15    local tutorial = Instance.new('IntValue')
View all 47 lines...

1 answer

Log in to vote
0
Answered by 2 years ago

Hello! Try this code instead:

01local DSS = game:GetService("DataStoreService")
02local Store = DSS:GetDataStore("StoreValues")
03 
04game.Players.PlayerAdded:Connect(function(plr)
05 
06    local leaderstats = Instance.new("Folder")
07    leaderstats.Name = "leaderstats"
08    leaderstats.Parent = plr
09 
10    local King = Instance.new("IntValue")
11    King.Name = "KingPoints"
12    King.Parent = leaderstats
13 
14    local Tutorial = Instance.new("IntValue")
15    Tutorial.Name = 'Tutorial'
View all 44 lines...

If you want an explanation, you can ask and you shall recieve.

0
is still not working, could it be because i'm changing the "Tutorial" value from a local script? MpAlex 16 — 2y
0
Yes, that's what is causing it. The server can't read your client. You can use RemoteEvent to change the values from a server. Good luck! LikeableEmmec 470 — 2y
0
indeed it worked now, thank you for the help MpAlex 16 — 2y
Ad

Answer this question