Whats wrong with my data Store Script

I’m testing my Data Store Script that stores 2 values, Level data and XP data. It saves the data in studio, I can tell because when I look at my data with the “DataStore Editor” plugin it shows that I have data, but if I test the script in an actual game, like actually playing the game, I always spawn in with 0 Level Data and I do edit my Level Data in the console to test it, its just that when I leave and join back I have 0 Level data instead of whatever I put. Right now I am only testing my Level Data, not XP.

local dataservice = game:GetService("DataStoreService")
local LevelData = dataservice:GetDataStore("PlayerLevels")

local function savedata(plyr)
	local id = "Player_"..plyr.UserId

	local Data = {

		level = plyr.leaderstats.Level.Value,
		XP = plyr.XP.Value

	}



	local success, errormessage = pcall(function()
		LevelData:SetAsync(id, Data)
	end)

	if success then
		print("dayta saved")
	else
		print("error saving dayta")
		warn(errormessage)
	end

end

game.Players.PlayerAdded:Connect(function(plyr)
	wait(0.1)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"

	
	local XP = Instance.new("IntValue")
	XP.Name = "XP"

	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Parent = leaderstats
	
	local id = "Player_"..plyr.UserId
	
	local Data
	local success, errormessage = pcall(function()
		Data = LevelData:GetAsync(id)
	end)
	
	if success then
		if Data then
			level.Level.Value = Data.Level
			XP.Value = Data.XP
			leaderstats.Parent = plyr
			XP.Parent = plyr
           end
	end
	
	spawn(function()
		while true do
			wait(60)
			print("Saving")
			savedata(plyr)
		end
	end)

	
end)


game.Players.PlayerRemoving:Connect(function(plyr)
	savedata(plyr)
end)


game:BindToClose(function()
	for i, plyr in pairs(game.Players:GetPlayers()) do
		savedata(plyr)
	end
end)



----NEW----

Clarification
Every time i go to test my script in an actual game, it doesnt load my data. Though, if i test it in the studio, The Data Store plugin I use to see data storages shows that it saved the data, but it doesnt load it when i go back into the test mode on studio, im pretty sure this is also happening on the actual game version.

local dataservice = game:GetService("DataStoreService")
local LevelData = dataservice:GetDataStore("PlayerLevels")

local function savedata(plyr)
	local id = "Player_"..plyr.UserId

	local Data = {

		Level = plyr.leaderstats.Level.Value,
		XP = plyr.XP.Value

	}



	local success, errormessage = pcall(function()
		LevelData:SetAsync(id, Data)
	end)

	if success then
		print("dayta saved")
	else
		print("error saving dayta")
		warn(errormessage)
	end

end

game.Players.PlayerAdded:Connect(function(plyr)
	wait(0.25)
	
	local XP = Instance.new("IntValue")
	XP.Name = "XP"
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plyr
	XP.Parent = plyr

	
	local IntLevel = Instance.new("IntValue")
	IntLevel.Name = "Level"
	IntLevel.Parent = leaderstats
	
	local id = "Player_"..plyr.UserId
	
	local Data
	local success, errormessage = pcall(function()
		Data = LevelData:GetAsync(id)
	end)
	
	if success then
		if Data then
			IntLevel.Value = Data.Level
			XP.Value = Data.XP
		end
	end
	
	spawn(function()
		while true do
			wait(60)
			print("Saving")
			savedata(plyr)
		end
	end)
end)


game.Players.PlayerRemoving:Connect(function(plyr)
	savedata(plyr)
end)


game:BindToClose(function()
	for i, plyr in pairs(game.Players:GetPlayers()) do
		savedata(plyr)
	end
end)


I think it should be at #help-and-feedback:code-review.

I think I found the issue. It looks like a simple typo.

When your loading your data you are setting the the Level value to Data.Level.
But in your saving code you save it as Data.level with a lowercase L.

You need to make sure both have the exact same name including the case that the letters are in

Why are you doing level.Level.Value? It should be level.Value. Also as @Elocore mentioned, make sure its Data.level not Data.Level.

I fixed the typo you pointed out(thanks for doing that its always the small things for me) but its still not working. I edited the post to have the new updated version to see if im still missing things.

Thank you for pointing this out, but i fixed the typo you pointed out and its still not working. I updated the post to have the new version of my script so you can still point out more typos if you see any