does anyone know how i can load a profile withoud a player being online or point me in the right way i am making an admin tool that can local change players data wich work but i also have a toggle to do it directly in the datastore if there offline
but going over the code im getting confused with the profile release and stuff
local Players = game:GetService("Players")
local ProfileService = require(game.ServerScriptService.PlayerData.ProfileService)
local ProfileTemplate = require(game.ServerScriptService.PlayerData.ProfileTemplate)
local ProfileStore = ProfileService.GetProfileStore(
game.ServerStorage.Settings.DataStorePrefix.Value,
ProfileTemplate
)
local Profiles = {}
local function onPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_" .. player.UserId,
"ForceLoad"
)
if profile then
profile:Reconcile() -- Fill in missing variables from ProfileTemplate (optional)
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("A1")
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick("A2")
end
end
local function onPlayerRemoving(player)
local profile = Profiles[player]
if profile then
require(game.ServerScriptService.PlayerData.Save).skill(require(game.ServerScriptService.Var),player)
profile:Release()
print("saved player",player,profile)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile.Data
end
end
return DataManager
any ideas how i convert this to also work with loading someone elses profile so i can edit it
it also seems to require an player object i only have a player id to work with if hes offline