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

Data Stores will not load data. How to fix?

Asked by 5 years ago

This is my code:

01local DataStoreService = game:GetService("DataStoreService")
02local PointsStore = DataStoreService:GetDataStore("BBSystems", "PointsValueHolder")
03 
04game.Players.PlayerAdded:Connect(function(Player)
05    local Key = "uid_" .. Player.UserId
06    local leaderstats = Instance.new("Folder")
07    local Points = Instance.new("NumberValue")
08    local Rank = Instance.new("StringValue")
09 
10    leaderstats.Parent = Player
11    leaderstats.Name = "leaderstats"
12 
13    Points.Parent = leaderstats
14    Points.Name = "Points"
15    Points.Value = PointsStore:GetAsync(Key)
View all 25 lines...

and for some reason It will not load the data up when the play joins (Im not sure if it saves it either)

If you could help, that would be much appreciated!

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

try using a pcall to get the data and set it to a variable. this always works for me

01local aDataStore = game:GetService("DataStoreService"):GetDataStore("aDataStore")
02 
03game.Players.PlayerAdded:Connect(function(Player)
04    local Key = "uid_" .. Player.UserId
05    local leaderstats = Instance.new("Folder")
06    local Points = Instance.new("NumberValue")
07    local Rank = Instance.new("StringValue")
08 
09    leaderstats.Parent = Player
10    leaderstats.Name = "leaderstats"
11 
12    Points.Parent = leaderstats
13    Points.Name = "Points"
14    Points.Value = aDataStore:GetAsync(Key)
15 
View all 35 lines...
0
Doesn't work.. ItsDodgee 0 — 5y
0
It works for me. here, I'll edit it to show the final code. you need to join an actual game by the way- data won't save in studio. I actually did change a few things but it works- saves points and gets the players current group rank. accept my answer if everything works :) Spiritlotus 151 — 5y
0
Doesn't work.. Where is your script placed? ItsDodgee 0 — 5y
0
a server script under ServerScriptStorage Spiritlotus 151 — 5y
View all comments (4 more)
0
Nothing ItsDodgee 0 — 5y
0
I edited my answer, are you sure your doing everything? I have this very script under serverscriptstorage and it works. you must be doing something wrong. Spiritlotus 151 — 5y
0
I imputed the code into a script, put that script in serverscriptstorage but nothing ItsDodgee 0 — 5y
0
do you have discord? ill help koala#6590 i dont know why its not working for you. it works for me and it only saves IN GAME not in STUDIO Spiritlotus 151 — 5y
Ad

Answer this question