Recently, I started using Profile service because of its resilience to many problems. However, save was automatic, additionaly save when session completed (profile:Release()).
I tried to save profile.Data in another player’s table, and use it to rewrite profile.Data when PlayerRemoving is fired and rewrite PreviousData when Save button is pressed, however none of these worked.
-- short code of what have I tried
local PreviousSave = {}
local Profiles = {}
local ProfileService = require(script.ProfieService)
local ProfileStore = ProfileService.GetProfileStore("PlayerData", Templates)
game.Players.PlayerAdded:Connect(function(player)
local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId, "ForceLoad")
if profile ~= nil then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick("")
end)
if player:IsDescendantOf(game.Players) then
Profiles[player] = profile
PreviousSave = profile.Data
else
profile:Release()
end
else
player:Kick("")
return
end
end
game.Players.PlayerRemoving:Connect(function(player)
local profile = Profiles[player]
if profile ~= nil then
profile = PreviousSave
profile:Release()
end
end
I would like to know if it’s even possible to disable auto-save and do it manually (for example, via a button), and also end the session without additional saving?
(The manual saving should be one of the main parts of the game)