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

DataStore Not Saving anything no errors or stuff!?

I am trying to save a table but is it is not saving, studio access to api is enabled and all. i might not be able to reach you tonight but thanks if you can help me:

Data = game:GetService("DataStoreService")
SaveData = Data:GetDataStore("PlayerSave1")
HasPlayed = Data:GetDataStore("PlayerHasPlayed")
DefaultSave = {0,0,0}

function LoadSave(plr)
	local id = tostring(plr.UserId)
	local mats = game.ReplicatedStorage.Materials
	local saveFile = nil
	saveFile = SaveData:GetAsync(id) or DefaultSave
	local PlayerFolder = Instance.new("Folder",mats)
	PlayerFolder.Name = plr.Name
	local Wood = Instance.new("NumberValue",PlayerFolder)
	Wood.Name = "Wood"
	Wood.Value = saveFile[0]
	local Stone = Instance.new("NumberValue",PlayerFolder)
	Stone.Name = "Stone"
	Stone.Value = saveFile[0]
	local Exp = Instance.new("NumberValue",PlayerFolder)
	Exp.Name = "Exp"
	Exp.Value = saveFile[0]
end

function Save(plr)
	local id = tostring(plr.UserId)
	
	local mats = game.ReplicatedStorage.Materials:WaitForChild(plr.Name)
	
	local success, err = pcall(function()
		SaveData:SetAsync(id,{mats.Wood.Value,mats.Stone.Value,mats.Exp.Value})
	end)
	
	if not success then
		warn(err)
	end
end

local players = game:GetService("Players")

players.PlayerAdded:Connect(LoadSave)
players.PlayerRemoving:Connect(Save)

also i do not get any errors i have been trying to work on this for 3 days help is much appreciated and just thanks for taking the time for reading this. doeschickens,

1 comment

0

i have the same problem as well but if you havent already turn on api services

1 answer

I Used DataStore2: here it worked amazing first try! i highly recommend you try it!

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