I need help on DataStore2

I am new to using Datastore2. Why doesn’t my save work?
image

local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")

datastore2.Combine("Wins")

game.Players.PlayerAdded:Connect(function(playeradded)
	local wins = datastore2("Wins", playeradded)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "Data"
	leaderstats.Parent = playeradded
	local actualleaderstats = leaderstats:Clone()
	actualleaderstats.Name = "leaderstats"
	actualleaderstats.Parent = playeradded
	
	local winsstat = Instance.new("NumberValue")
	winsstat.Name = "Wins"
	winsstat.Parent = leaderstats
	winsstat:Clone().Parent = actualleaderstats
	winsstat.Value = wins:Get(0)

	
	wins:OnUpdate(function(newWins)
		game.Players[playeradded.Name].Data.Wins.Value = newWins
		game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
	end)

end)

Please someone at least help me with this script, I can’t wait long.

Maybe have to do with the fact that it’s not saving because it has not changed from the original value.

I don’t think it’s the original value that I changed.

Can someone please help me ://

try this one

local DataStore2 = require(1936396537)
local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")

DataStore2.Combine("MasterKey","Wins")

game.Players.PlayerAdded:Connect(function(playeradded)
	local wins = DataStore2("Wins", playeradded)

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "Data"
	leaderstats.Parent = playeradded
	local actualleaderstats = leaderstats:Clone()
	actualleaderstats.Name = "leaderstats"
	actualleaderstats.Parent = playeradded

	local winsstat = Instance.new("NumberValue")
	winsstat.Name = "Wins"
	winsstat.Parent = leaderstats
	winsstat:Clone().Parent = actualleaderstats
	winsstat.Value = wins:Get(0)


	wins:OnUpdate(function(newWins)
		game.Players[playeradded.Name].Data.Wins.Value = newWins
		game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
	end)

end)

It doesn’t save though, (SaveInStudio is on) and API Service is on too.

how bout this one

local DataStore2 = require(1936396537)
local events = Instance.new("Folder")
events.Name = "Events"
events.Parent = game:WaitForChild("ServerStorage")

DataStore2.Combine("Wins")

game.Players.PlayerAdded:Connect(function(plr)
	local wins = DataStore2("Wins",plr)

	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "Data"
	leaderstats.Parent = playeradded
	local actualleaderstats = leaderstats:Clone()
	actualleaderstats.Name = "leaderstats"
	actualleaderstats.Parent = playeradded

	local winsstat = Instance.new("NumberValue")
	winsstat.Name = "Wins"
	winsstat.Parent = leaderstats
	winsstat:Clone().Parent = actualleaderstats
	winsstat.Value = wins:Get(0)


	wins:OnUpdate(function(newWins)
		game.Players[playeradded.Name].Data.Wins.Value = newWins
		game.Players[playeradded.Name].leaderstats.Wins.Value = newWins
	end)

end)

Still doesn’t work either though

DataStore2 won’t save values that weren’t updated, this is to prevent consuming unnecessary data store budget. In your case, since you never seem to be updating wins, there is no need to save it, you will have to update it in order for DataStore2 to save it.

How can I make it save if it doesn’t save?

Why is no one helping me…???

We’re trying, try just using regular datastore instead if you can help it.

I prefer DataStore2 instead of regular datastore because of less bad consequences.

1 Like

I still need help just to let you know…

The script is the main script I’m using for updating and creating the Wins as leaderstats, and the module script as DataStore2.

why don’t you use a regular datastore
the regular datastore is easier

Like what I said from above, I prefer DataStore2 instead of regular datastore because of less bad consequences, which is I don’t want players to complain if they lose data automatically since they can lose data, which I know I can do that too but, I still prefer using this.

may I modify the script??

(ignore this)

Yes you can but what script specifically?

I want to change the script a little bit