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

DataStoreService doesn't seem to be working, why?

Asked by 6 years ago
Edited 6 years ago

I have already made a script that makes the empty data file, but the one that saves it i have never gotten to work. am i missing anything or doing anything wrong?

i want to be able to load the datastore up to an IntValue(it is saving numbers) and get it save data from IntValues

local DataStore = game:GetService("DataStoreService"):GetDataStore("CompanyData")

game.Players.PlayerRemoving:connect(function(Player)
    Player:WaitForDataReady()
local Stats = Player:FindFirstChild("Data"):GetChildren()
    for i = 1, #Stats do
        DataStore:SetAsync(Stats[i].Name,Stats[i].Value)
    end
end)

game.Players.PlayerAdded:connect(function(Player)
    Player:WaitForDataReady()
local Stats2 = Player:FindFirstChild("Data"):GetChildren()
    for i = 1, #Stats2 do
        Stats2[i].Value = DataStore:GetAsync(Stats2[i].Name)
    end
end)
0
"Data" is a folder with IntValues i hope to move numbers to and from the DataStore Creeper_Dude158 11 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I’m not the best with DataStores, but it seems like you’re getting the DataStore service but then trying to get data in the player in something called “Data”? I don’t think that’s how DataStores work, unless you have another script that puts an object named “Data” in the player.

I think the saving data is fine, as it seems like you’re trying to save data based on the “Data” in the player. When you get the data though, the “Data” in the player wasn’t updated by the data you saved, so it’s not going to work.

I’d like to fix your problem but DataStores confuse me and I got my info from the wiki. I only pointed out why it’s not working. Maybe someone else can fix your scripts?

If you want to learn or read more about DataStores, you can read a tutorial about it here.

Ad

Answer this question