Datastore not saving

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)

Is API Services enabled in your game?
Are you trying this in studio or in game?

API services is enabled. I am trying it in studio.

Try it in game. Studio is incredibly buggy with DataStores.

Let me know if it works or not

It did not work. Both of the values still wont save

This was not tricky at all. I forgot to add “-” to “Resets” on line 32. Thanks for all the help though

Ah ok. Glad i could help a little

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.