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)
COMMUNITY QUESTION
Why wont the datastore work? It use to work but all of the sudden it wont?
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
