Hello. I am new to datastore. I tried making a new datastore (ResetManager) but the value is not saving. There are 2 values, “Flowers” and “Resets”. Surprisingly, both values wont save. There are no errors in the output, only the “success” messages.
local DataStore = game:GetService("DataStoreService")
local FlowerManger = DataStore:GetDataStore("flrs")
local ResetManager = DataStore:GetDataStore("resets")
local PlyrServ = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = player
local flrs = Instance.new("IntValue")
flrs.Name = "Flowers"
flrs.Value = 0
flrs.Parent = ls
local resets = Instance.new("IntValue")
resets.Name = "Resets"
resets.Value = 0
resets.Parent = ls
local data
local reset
local success,errormessage = pcall(function()
data = FlowerManger:GetAsync(player.UserId.."-Flowers")
end)
if success then
flrs.Value = data
print("Loaded In Data")
else
warn(errormessage)
print("Failed To Load Data")
end
local success3, errormessage3 = pcall(function()
reset = ResetManager:GetAsync(player.UserId.."resets")
end)
if success3 then
resets.Value = reset
print("Resets have been loaded in")
else
warn(errormessage3)
print("Resets have failed to load in")
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success,errormessage = pcall(function()
FlowerManger:SetAsync(player.UserId.."-Flowers",player.leaderstats.Flowers.Value)
end)
if success then
print("Data Success")
else
print("Data Failed")
warn(errormessage)
end
local success1, errormessage2 = pcall(function()
ResetManager:SetAsync(player.UserId.."-Resets",player.leaderstats.Resets.Value)
end)
if success1 then
print("Reset Loaded Sucessfully")
else
print("Reset Failed To Load")
warn(errormessage2)
end
end)