Issue with data save

I wanted to create new values to save inside the player database but i get this error
Screenshot 2024-09-22 212917
why does this happen? this is the whole data save script

local datastoreservice = game:GetService("DataStoreService")
local datastore = datastoreservice:GetDataStore("DataStoreKey223")

local players = game:GetService("Players")

local function SaveData(player : Player)
	local playerusid = player.UserId
	
	local data = {
		Coins = player.leaderstats.Coins.Value,
		Diamonds = player.leaderstats.Diamonds.Value,
		Wins = player.leaderstats.Wins.Value,
		CurrentCart = player.CurrentCart.Value,
		CurrentAbility = player.CurrentAbility.Value,
		CurrentQuest = player.CurrentQuest.Value,
		DragonBalls = player.DragonBalls.Value,
		StudQuest = player.StudQuest.Value,
		WinQuest = player.WinQuest.Value,
		TimeQuest = player.TimeQuest.Value,
		["BoughtCarts"] = {}
	}
	local BoughtCartFold = player:FindFirstChild("BoughtCarts")
	local BoughtCartTable = data["BoughtCarts"]
	
	for _,SaveBC in pairs(BoughtCartFold:GetChildren()) do
		if SaveBC:IsA("ValueBase") then
			table.insert(BoughtCartTable,SaveBC.Name)
		end
	end

	local success, errormessage = pcall(function()
		datastore:SetAsync(playerusid, data)
	end)
	if success then
		print("Data successfully saved!")
	else
		print("There was an error saving your data.")
		warn(errormessage)
	end
end

players.PlayerAdded:Connect(function(player : Player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Value = 0
	coins.Parent = leaderstats
	
	local diamonds = Instance.new("IntValue")
	diamonds.Name = "Diamonds"
	diamonds.Value = 0
	diamonds.Parent = leaderstats
	
	local wins = Instance.new("IntValue")
	wins.Name = "Wins"
	wins.Value = 0
	wins.Parent = leaderstats
	
	local currentcart = Instance.new("StringValue")
	currentcart.Name = "CurrentCart"
	currentcart.Parent = player
	currentcart.Value = "BasicSled"
	
	local currentability = Instance.new("StringValue")
	currentability.Name = "CurrentAbility"
	currentability.Parent = player
	currentability.Value = "Dash"
	
	local boughtcarts = Instance.new("Folder")
	boughtcarts.Name = "BoughtCarts"
	boughtcarts.Parent = player
	
	local gamepassesfolder = Instance.new("Folder")
	gamepassesfolder.Name = "Gamepasses"
	gamepassesfolder.Parent = player
	
	local vippass = Instance.new("BoolValue")
	vippass.Name = "VipPass"
	vippass.Value = false
	vippass.Parent = gamepassesfolder
	
	local santapass = Instance.new("BoolValue")
	santapass.Name = "SantaPass"
	santapass.Value = false
	santapass.Parent = gamepassesfolder
	
	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Value = 0
	points.Parent = player
	
	local points = Instance.new('NumberValue')
	points.Name = "PointMultiply"
	points.Value = 1
	points.Parent = player
	
	local ownedtrails = Instance.new('Folder')
	ownedtrails.Name = "OwnedTrails"
	ownedtrails.Parent = player
	
	local currenttrail = Instance.new('StringValue')
	currenttrail.Name = "EquippedTrail"
	currenttrail.Parent = player
	currenttrail.Value = ""
	
	local quests = Instance.new("Folder")
	quests.Name = "Quests"
	quests.Parent = player
	
	local currentquest = Instance.new("StringValue")
	currentquest.Name = "CurrentQuest"
	currentquest.Parent = player
	currentquest.Value = ""
	
	local dragonballs = Instance.new("IntValue")
	dragonballs.Name = "DragonBalls"
	dragonballs.Parent = player
	dragonballs.Value = 0
	
	local studquestprog = Instance.new("IntValue")
	studquestprog.Name = "StudQuest"
	studquestprog.Parent = quests
	studquestprog.Value = 1
	
	local winquest = Instance.new("IntValue")
	winquest.Name = "WinQuest"
	winquest.Parent = quests
	winquest.Value = 1
	
	local timequest = Instance.new("IntValue")
	timequest.Name = "TimeQuest"
	timequest.Parent = quests
	timequest.Value = 1

	
	local LoadedData = datastore:GetAsync(player.UserId)
	if LoadedData ~= nil then
		coins.Value = LoadedData["Coins"]
		diamonds.Value = LoadedData["Diamonds"]
		wins.Value = LoadedData["Wins"]
		currentcart.Value = LoadedData["CurrentCart"]
		currentability.Value = LoadedData["CurrentAbility"]
		currentquest.Value = LoadedData["CurrentQuest"]
		dragonballs.Value = LoadedData["DragonBalls"]
		studquestprog.Value = LoadedData["StudQuest"] 
		winquest.Value = LoadedData["WinQuest"] 
		timequest.Value = LoadedData["TimeQuest"]
		local BoughtCartsLoad = LoadedData["BoughtCarts"]
		local BoughtTrailsLoad = LoadedData["OwnedTrails"]
		if BoughtCartsLoad ~= nil then
			for _,GiveLoad in pairs(BoughtCartsLoad) do
				local NewCart = Instance.new("StringValue")
				NewCart.Name = GiveLoad
				NewCart.Parent = boughtcarts
			end
		end
		if BoughtTrailsLoad ~= nil then
			for _,GiveLoad in pairs(BoughtTrailsLoad) do
				local NewTrail = Instance.new("StringValue")
				NewTrail.Name = GiveLoad
				NewTrail.Parent = boughtcarts
			end
		end
		
		
		
		
	end
	
	--[[local data
	local success, errormessage = pcall(function()
		data = datastore:GetAsync(player.UserId)
	end)
	if success then
		coins.Value = data.Coins
		diamonds.Value = data.Diamonds
	else
		coins.Value = 0
		diamonds.Value = 0
		currentcart.Value = "BasicSled"
	end]]--
	while wait(1) do
		if dragonballs.Value == 7 then 
			local kintoun = Instance.new("StringValue")
			kintoun.Name = "FlyingNimbus"
			kintoun.Parent = boughtcarts
		end
		if 900 >= timequest.Value then
			timequest.Value = timequest.Value + 1

		end
	end

end)

players.PlayerRemoving:Connect(function(player : Player)
	SaveData(player)
end)

game:BindToClose(function()
	for _, player in players:GetPlayers() do
		SaveData(player)
	end
end)

it only says it for specifically studquestprog, winquest, and timequest, but not the other ones i seriously dont know why it errors and doesnt save

My guess is that you’re trying to save StudQuest with the value player.StudQuest.Value instead of player.Quests.StudQuest.Value. The same goes for WinQuest and TimeQuest.

im not really sure if its true since if that was the case then id have to in leaderstats in the coins wins and diamonds pathway too but i dont have to

You should try printing out the table called data before you save