I have a script and values already in place. For some reason nothing is saving and its driving me crazy! Here it is can someone tell me whats wrong.

--[Designed by proo34]--
local DataBaseStore = game:GetService("DataStoreService"):GetDataStore("game_save_SR")
local Statsholder = script.Stats


game.Players.PlayerAdded:Connect(function(NewPlayer)
	
	local Key = "Player-ID:" .. NewPlayer.userId
	local GetSave = DataBaseStore:GetAsync(Key)
	
	local DataBaseFolder = Instance.new("Folder", NewPlayer)
	DataBaseFolder.Name = "PlayerStats"
	
	for i, Stats in pairs(Statsholder:GetChildren()) do
		local NewStats = Instance.new(Stats.ClassName)
		NewStats.Name = Stats.Name
		NewStats.Value = Stats.Value
		NewStats.Parent = DataBaseFolder
	end
	
	if GetSave then
		-- player has data
		for i, Stats in pairs(script.Stats:GetChildren()) do
			DataBaseFolder[Stats.Name].Value = GetSave[i]
			print (i, Stats.Name, Stats.Value)
		end
		
	else
		
	while wait(30) do -- auto save	
		
		local StatsToSave = {}
		
		for i, Stats in pairs(DataBaseFolder:GetChildren()) do
			table.insert(StatsToSave, Stats.Value)
		end
		DataBaseStore:SetAsync(Key, StatsToSave)
	
	end
	
game.Players.PlayerRemoving:Connect(function(OldPlayer)
	
	local Key = "Player-ID" .. OldPlayer.userId
end)
	
		local StatsToSave = {}
		
		for i, Stats in pairs(DataBaseFolder:GetChildren()) do
			table.insert(StatsToSave, Stats.Value)
		end
		DataBaseStore:SetAsync(Key, StatsToSave)
		end
end)

5 comments

0

Thanks! Did so.

0

Lol why did you put your name at the top.

0

So people don't clone my code. People do it so much and it hurts because I put a lot of time and effort in my code! Lol

0

It's not like they can't remove the comment