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

Is it impossible to save "StringValue" through DataStore?

Asked by 6 years ago
Edited 6 years ago

I won't my datastore to save "StringValue" is it unsupported or it is a script error it just changes it to a number?

Server Script:

01--DataStores
02local DataStore = game:GetService("DataStoreService")
03local DataStore_oofs = DataStore:GetDataStore("SaveSystem_oofs")
04local DataStore_rank = DataStore:GetDataStore("SaveSystem_rank")
05 
06--Create leaderboard
07game.Players.PlayerAdded:Connect(function(player)
08    --Create Leaderboard
09    local LeaderBoard = Instance.new("Folder",player)
10    LeaderBoard.Name = "leaderstats"
11    --Create Values
12    local Oofs = Instance.new("NumberValue",LeaderBoard)
13    Oofs.Name = "Oofs"
14    Oofs.Value = 0
15    local Rank = Instance.new("StringValue",LeaderBoard)
View all 32 lines...

If there is a way to save string values, please explain?

0
Although your datastore setup isnt "wrong" i highly recommend looking into tables! You wont regret it. DinozCreates 1070 — 6y

2 answers

Log in to vote
1
Answered by
fr2013 88
6 years ago

If the player is added, then it would get a sync to the strings after dying I guess. So insert this inside game.Players.PlayerAdded:Connect(function(player) and replace it with the other GetASync

1local InStudio = game:GetService("RunService"):IsStudio()
2 
3if not InStudio then
4        Oofs.Value = DataStore_oofs:GetAsync(tostring(player.userId)) or 0
5        Rank.Value = DataStore_rank:GetAsync(tostring(player.userId)) or "New Oofer"
6    else
7        Oofs.Value = DataStore_oofs
8        Rank.Value = DataStore_rank
9    end
Ad
Log in to vote
0
Answered by
Shadrz 40
6 years ago
Edited 6 years ago

This is probably the solution.

01--DataStores
02local DataStore = game:GetService("DataStoreService")
03local DataStore_oofs = DataStore:GetDataStore("SaveSystem_oofs")
04local DataStore_rank = DataStore:GetDataStore("SaveSystem_rank")
05 
06--Create leaderboard
07game.Players.PlayerAdded:Connect(function(player)
08    local key = "id_" .. player.UserId
09    --Create Leaderboard
10    local LeaderBoard = Instance.new("Folder",player)
11    LeaderBoard.Name = "leaderstats"
12    --Create Values
13    local Oofs = Instance.new("NumberValue",LeaderBoard)
14    Oofs.Name = "Oofs"
15    Oofs.Value = 0
View all 38 lines...

Answer this question