Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

DataStoreService doesn't seem to be working, why?

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)

1 comment

0

"Data" is a folder with IntValues i hope to move numbers to and from the DataStore

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.