DataStore2 Stuck?

Hello everyone, I tried combining DataStore2 before with two leaderstats, and it worked nicely, but then whenever I tried calling the second leaderstats in the game, it said the error that two datas can not be used. So then I split the two leaderstats in to two different scripts, but now the leaderstas is stuck and is not working either. The gold works, but the level does not. Why?

local DataStore2 = require(1936396537)

DataStore2.Combine("ChickenKey","Level")

game.Players.PlayerAdded:Connect(function(plr)
	local dataLevel = DataStore2("Level", plr)
	local folder = Instance.new("Folder",plr)
	folder.Name = "leaderstats"

	local level = Instance.new("IntValue", folder)
	level.Name = "Level"

	if dataLevel:Get() ~= nil then
		level.Value = dataLevel:Get()
	else
		level.Value = 0
	end

	level.Changed:Connect(function()
		dataLevel:Set(level.Value)
	end)

end)
local DataStore2 = require(1936396537)

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

game.Players.PlayerAdded:Connect(function(plr)
	local dataGold = DataStore2("Gold", plr)
	local folder = Instance.new("Folder",plr)
	folder.Name = "leaderstats"

	local gold = Instance.new("IntValue", folder)
	gold.Name = "Gold"

	if dataGold:Get() ~= nil then
		gold.Value = dataGold:Get()
	else
		gold.Value = 100
	end

	gold.Changed:Connect(function()
		dataGold:Set(gold.Value)
	end)

end)

Not really sure why this would be happening. Have you considered using ProfileService instead?

My original script did not do this and this only happens to other player’s gold for some reason which I see as nil. Let me show you what I mean.

This picture shows how my Level is 0 but should actually be 1741. On the bottom, my level should have been 0 at least if it was actually 0 but instead if actually just shows nothing.

My understanding is DataStore2’s Get method takes an optional argument for a beginning value. Have you tried doing:

gold.Value = dataGold:Get(100)

instead of:

if dataGold:Get() ~= nil then
	gold.Value = dataGold:Get()
else
	gold.Value = 100
end

But this is not the problem of Gold but I will try this on level. This is most likely not the error or else my gold would not work either.

Could you show exactly what error you were getting? Your original explanation isn’t super clear on what is going on


Another player’s level does not show either.

Could you show line 28 of ServerScriptService.NameTagScript

That is not the problem. It just shows that Level system is not valid for somer eason. I have used the Nametag script for a long time. Line 28 is just player.leaderstats.Level.Value

Not really sure, I don’t really understand what issue you’re running into here and DataStore2 has a pretty weird way of doing all these things. Good luck though.

This could be an error of something else maybe, but I do not think so.

Can you show the whole Developer Console?

Okay give me a second to print screen it.