local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("datatest")
game.Players.PlayerAdded:Connect(function(plr)
local axes = Instance.new("Folder",plr)
axes.Name = "axes"
local Homemadeaxe = Instance.new("BoolValue",axes)
Homemadeaxe.Name = "Homemadeaxe"
local Normalaxe = Instance.new("BoolValue",axes)
Normalaxe.Name = "Normalaxe"
local dataofuser = ds:GetAsync(plr.UserId)
if dataofuser ~= nil then -- anything but nil
print("Found data for " .. plr.Name)
Homemadeaxe.Value = ds[1]
Normalaxe.Value = ds[2]
else
print("Replacing no data with new data.")
Homemadeaxe = true
Normalaxe = false
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {}
table.insert(datasave, plr:WaitForChild("Homemadeaxe"):WaitForChild("BoolValue").Value)
table.insert(datasave, plr:WaitForChild("Normalaxe"):WaitForChild("BoolValue").Value)
local success,response = pcall(function()
ds:SetAsync(plr.UserId, datasave)
end)
if success then
print("succesfully saved data of " .. plr.Name)
else
warn(response)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {}
table.insert(datasave, plr:WaitForChild("Homemadeaxe"):WaitForChild("BoolValue").Value)
table.insert(datasave, plr:WaitForChild("Normalaxe"):WaitForChild("BoolValue").Value)
local success,response = pcall(function()
ds:SetAsync(plr.UserId, datasave)
end)
print(success)
print(response)
if success then
print("succesfully saved data of " .. plr.Name)
else
warn(response)
end
end)
local success, err = nil
local attempt = 1
repeat
success, err = pcall(function()
ds:SetAsync(plr.UserId, datasave)
end)
attempt += 1
until success or attempt == 5
if success then
print("Data saved")
else
warn(err)
end
game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {}
table.insert(datasave, plr:WaitForChild("Homemadeaxe"):WaitForChild("BoolValue").Value)
table.insert(datasave, plr:WaitForChild("Normalaxe"):WaitForChild("BoolValue").Value)
local success, err = nil
local attempt = 1
repeat
success, err = pcall(function()
ds:SetAsync(plr.UserId, datasave)
end)
attempt += 1
until success or attempt == 5
if success then
print("Data saved")
else
warn(err)
end
print(success)
if success then
print("succesfully saved data of " .. plr.Name)
else return
end
end)