ProfileStore access and change data

Hey, I’m using loleri’s ProfileStore, and I was wondering if it would be possible to change the profiles data from another file, rather than the main manager file. I have the file setup as followed instructed in the tutorial, “basic usage”.

This is my ProfileManager file:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local ServerScriptService = game:GetService("ServerScriptService")
local ProfileStore = require(ServerScriptService.Packages.ProfileStore)
local Template = require(ServerScriptService.ProfileManager.Template)
local Leaderstats = require(ReplicatedStorage.Modules.Leaderstats)
local Players = game:GetService("Players")

local environment = "Production"

if RunService:IsStudio() then
	environment = "Development"
end

local PlayerStore = ProfileStore.New(environment, Template)
type Profile = typeof(PlayerStore:StartSessionAsync())
local Profiles: { [Player]: Profile } = {}

local function PlayerAdded(player: Player)
	local profile = PlayerStore:StartSessionAsync(tostring(player.UserId), {
		Cancel = function()
			return player.Parent ~= Players
		end,
	})

	local leaderstats = Leaderstats.new(player)

	if profile ~= nil then
		profile:AddUserId(player.UserId)
		profile:Reconcile()

		profile.OnSessionEnd:Connect(function()
			Profiles[player] = nil
			player:Kick("Profile session has ended, please rejoin")
		end)

		if player.Parent == Players then
			Profiles[player] = profile

			local level = leaderstats:CreateValue("Level", profile.Data.Level)
			local money = leaderstats:CreateValue("Bank Account", profile.Data.Money)

			profile.OnAfterSave:Connect(function(data)
				level:UpdateValue(data.Level)
				money:UpdateValue(data.Money)
			end)
		else
			profile:EndSession()
		end
	else
		player:Kick("Failed to load profile data, please rejoin")
	end
end

for _, player in Players:GetPlayers() do
	task.spawn(PlayerAdded, player)
end

Players.PlayerAdded:Connect(PlayerAdded)

Players.PlayerRemoving:Connect(function(player)
	local profile = Profiles[player]

	if profile ~= nil then
		profile:EndSession()
	end
end)

The project structure is as followed:
image

I’m pretty new to scripting so sorry if this is a silly question!

Also, please let me know if I have set up the script incorrectly, as I am pretty unsure I have done so

Nevermind, I think I figured it out

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