Saving Progress With NPC In Data

I know this is a bit overkill for your level but, I’d recommend using EasyProfile which is part of the canary suite by @jmesrje which essentially is just a Profile Service wrapper. I recommend reading the documentation/guide for further understanding

I couldn’t really indent it properly because I can’t do Tab

-- ... require the module

local ProfileKey = "GeneralPlayerData" -- an unique key to store the data on
local ProfileTemplate = {

TheNPC = { -- the npc data you're referring to for each player

AmountBoughtChi = 0

}

} -- the structure of the profile store
local PlayerProfileStore = EasyProfile.CreateProfileStore(ProfileKey, ProfileTemplate)

local function OnPlayerAdded(player: Player)

-- :LoadProfileAsync(string|Player key, boolean? reconcileData, string? profileClaimedHandler)
PlayerProfileStore:LoadProfileAsync(player, true, "ForceLoad"):After(function(success, playerProfile)
if not success then
return
end

-- get the profile data and do something with it
local ProfileData = playerProfile:GetProfileData()

-- to get the npc data:
local NPCData = ProfileData.TheNPC
local AmountBoughtChi = NPCData.AmountBoughtChi

-- to set the npc data:
ProfileData.TheNPC.AmountBoughtChi += 1 -- increase the chi whenever the player joins and successfully loads the data

end)

end