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

Why wont the datastore work? It use to work but all of the sudden it wont?

local Data = game:GetService("DataStoreService"):GetDataStore("ThrowsDataSaver")

game.Players.PlayerAdded:Connect(function(plr)
	local folder = Instance.new("Folder", plr)
	folder.Name = "leaderstats"
	
	local Throws = Instance.new("IntValue", folder)
	Throws.Name = "Throws"
	Throws.Value = 0
	
	local dataLoad = Data:GetAsync(tostring(plr.UserId))
	
	if dataLoad then
		Throws.Value = dataLoad[1]
	end
end)
game.Players.PlayerRemoving:Connect(function(plr)
	Data:SetAsync(tostring(plr.UserId),{
		plr.leaderstats.Throws.Value
	})
end)

1 answer

Its most likely because you havent defined a game:BindToClose when the last player leaves the server shutdowns and which can cause data to not save, bc the playerremoving event may not execute on time (its unreliable)

see this article on how to properly save

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