Hello, I was following a tutorial on Datastores by @GEILER123456, and few days ago, there was this printing out.
What does this mean, and is there a solution to fix this?
Thank you.
Hello, I was following a tutorial on Datastores by @GEILER123456, and few days ago, there was this printing out.
What does this mean, and is there a solution to fix this?
Thank you.
We need to see your code to be able to assist with this issue, you likely must’ve accidentally done an error when following along
This is the script (I followed @GEILER123456’s tutorial on DataStores) :
local dataStoreService = game:GetService("DataStoreService")
local players = game:GetService("Players")
local dataStore = dataStoreService:GetDataStore("Name")
local function playerAdded(player)
local userId = player.UserId
local key = "Player_" .. userId
local data = dataStore:GetAsync(key)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = data or 0
money.Parent = leaderstats
print("Leaderstats loaded.")
end
local function save(player)
local userId = player.UserId
local key = "Player_" .. userId
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local moneyValue = leaderstats.Money.Value
local success, ret = pcall(dataStore.SetAsync, dataStore, key, moneyValue)
if success then
print("Data has been saved successfully!")
else
print("There was an error with saving a player's data" .. ret)
end
end
end
local function onShutDown()
wait(1)
end
game:BindToClose(onShutDown)
players.PlayerAdded:Connect(playerAdded)
for _, player in ipairs(players:GetPlayers()) do
playerAdded(player)
end
players.PlayerRemoving:Connect(save)
while true do
wait(60)
for _,player in ipairs(players:GetPlayers()) do
coroutine.wrap(save)(player)
end
end
When does this happen? When the player leaves or when it tries to autosave?
This error happens when it is auto saving every 60 seconds or when the player leaves the game.