This really worries me. lets pretend there is a cash value which saves/loads under my system. I had 42M cash and I lost it! It didn't save nor did the value re-load!
This is a super-simplified version of my data-store script to save you some time. Are there any faults in this script or any missing security? Thanks.
-- simplify the save process
local function saveData(key, saveData)
DataStore:SetAsync(key, saveData) -- save the data
end
game.Players.PlayerAdded:connect(function(player)
wait()
local key = "Player_" .. player.UserId
local plrData = DataStore:GetAsync(key) -- loading data
spawn(function()
while wait(60) and player.Parent == game.Players do
--Save key: {kos, volume}
saveData(key, {player.leaderstats.KOs.Value})--save the data
if player == nil then
break
end
print(player.Name .. "'s work was saved.")
end
end)
if plrData then
--Save format: {kos, volume}
player.leaderstats.KOs.Value = plrData[1] or 0 -- data save
else
--######ey: {kos, volume}
saveData(key, {player.leaderstats.KOs.Value})
end
game.Players.PlayerRemoving:connect(function(player)
--Save key: {kos, volume}
saveData("Player_" .. player.UserId, {player.leaderstats.KOs.Value}) -- save that data
end)

3 comments
Yea learn the basics and use pcall()!
hey use BindToClose and wait 30 seconds so you have 30 whole seconds if it errors!!1
Also, you should be more worried about https://devforum.roblox.com/t/recent-roblox-security-incident/53277