How do I fix this Data Saving Script?

Right now, this data script does nothing except place values into the player (the folders are put there by an external script, and API Requests and HTTPS Requests are turned ON)

local DEFAULT_PROFILE = {
	-- {{ INVENTORY }} --
	hotbar1 = "Fishing Rod",
	hotbar2 = "Wooden Pickaxe",
	hotbar3 = "Torch",
	hotbar4 = "",
	hotbar5 = "",
	hotbar6 = "",
	hotbar7 = "",
	hotbar8 = "",
	hotbar9 = "",




	-- [[ TOOLS ]] --
	["Fishing Rod"] = 1,
	["Torch"] = 1,
	-- (( COMMON )) --
	["Wooden Pickaxe"] = 1,
}
local ProfileService = require(script.ProfileService)
local Players = game:GetService("Players")
local GameProfileStore = ProfileService.GetProfileStore(
	"mainsavedata_009",
	DEFAULT_PROFILE
)
local Profiles = {}

local function loadUserData(player : Player, profile)
	
	for i,_ in pairs(profile.Data) do
		if not string.find(i,"hotbar") then
			local newVal = Instance.new("IntValue")
			newVal.Value = profile.Data[i]
			newVal.Name = i
			newVal.Parent = player:WaitForChild("Inventory")
		else -- table.find("funny", i)
			local newVal = Instance.new("StringValue")
			newVal.Value = profile.Data[i]
			newVal.Name = i
			newVal.Parent = player:WaitForChild("HotbarSlots")
		end
	end
	for _,v : IntValue in pairs(player:GetDescendants()) do
		if (v:IsA("StringValue") or v:IsA("NumberValue") or v:IsA("IntValue")) and (v.Parent == player or v.Parent == player:WaitForChild("Inventory") or v.Parent == player:WaitForChild("HotbarSlots")) then
			profile.Data[v.Name] = v.Value
		end
	end
	
end
local function PlayerAdded(player)
	local profile = GameProfileStore:LoadProfileAsync(
		"Player_" .. player.UserId,
		"ForceLoad"
	)
	if profile ~= nil then
		profile:Reconcile() 
		profile:ListenToRelease(function()
			Profiles[player] = nil
			player:Kick()
		end)
		if player:IsDescendantOf(Players) == true then
			Profiles[player] = profile
			loadUserData(player, profile)
		else
			profile:Release()
		end
	else
		player:Kick()
	end
end
for _, player in ipairs(Players:GetPlayers()) do
	coroutine.wrap(PlayerAdded)(player)
end
Players.PlayerAdded:Connect(PlayerAdded)

Players.PlayerRemoving:Connect(function(player)
	local profile = Profiles[player]
	if profile ~= nil then
		profile:Release()
	end
end)

return Profiles

(you can ignore all the items and spaces, unless they are the issue)

but the main issue I can see is that something in the script or something that isnt in the script is preventing data from being saved. If anyone can look into this, it would be a tremendous help to my game’s progress.

11 hours later, still no response?

fixed the issue, forgot a loop

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