-
What do you want to achieve?
I’m trying to save three values with a DataStore. -
What is the issue?
It gives me a warning, and the values don’t get saved. This is the warning:
-
What solutions have you tried so far?
I’ve searched “Roblox Studio DataStore Queue”, and I did get results but they saved different things, so that’s why I’m asking it here.
I’ve also looked at this page, but the warning doesn’t get mentioned:
Data Stores
This is the script I’m using:
local DataStoreService = game:GetService("DataStoreService")
local statsData = DataStoreService:GetDataStore("testData4")
game.Players.PlayerAdded:Connect(function(player)
local leaderstatsFolder = Instance.new("Folder", player)
leaderstatsFolder.Name = "leaderstats"
local steamsValue = Instance.new("NumberValue", leaderstatsFolder)
steamsValue.Name = "Steams"
steamsValue.Value = 0
local levelValue = Instance.new("NumberValue", leaderstatsFolder)
levelValue.Name = "Level"
levelValue.Value = 0
local rebirthsValue = Instance.new("NumberValue", leaderstatsFolder)
rebirthsValue.Name = "Rebirths"
rebirthsValue.Value = 0
local saves = {
player.leaderstats.Steams.Value,
player.leaderstats.Level.Value,
player.leaderstats.Rebirths.Value,
}
local data = statsData:GetAsync(player.UserId)
local succes, errormessage = pcall(function()
if data ~= nil then
steamsData = data[1]
levelData = data[2]
rebirthsData = data[3]
end
end)
if succes then
if data ~= nil then
player.leaderstats.Steams.Value = steamsData
player.leaderstats.Level.Value = levelData
player.leaderstats.Rebirths.Value = rebirthsData
print(player.Name.." 's data has been loaded!")
end
else
warn("There was an error while loading "..player.Name.."'s data!")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local saves = {
player.leaderstats.Steams.Value,
player.leaderstats.Level.Value,
player.leaderstats.Rebirths.Value,
}
local data = statsData:SetAsync(player.UserId,saves)
local succes, errormessage = pcall(function()
statsData:SetAsync(player.UserId,saves)
end)
if succes then
else
warn("There was an error while saving "..player.Name.."'s data!")
warn(errormessage)
end
end)
game:BindToClose(function()
print("No players detected in server, shutting down..")
wait(3)
end)