When I use :Release() on a loaded profile, it’s kicking my player. However I don’t want this to occur. I’m trying to :Release as I want to save 1 data set and load up a seperate data set for the player.
This is what I use to load plot data for a player
local function LoadPlotData(player, currentPlot)
local ProfileStore = ProfileService.GetProfileStore("Test_01", {
Exterior = {}, -- Roof / Walls
Interior = {}, -- Furniture / Walls / Floors + Roof
})
local Profile = ProfileStore:LoadProfileAsync("Plot_" .. currentPlot .. "_" .. player.UserId)
if Profile ~= nil then
Profile:AddUserId(player.UserId) -- GDPR compliance
Profile:Reconcile() -- Fill in missing variables from ProfileTemplate (optional)
-- The profile could've been loaded on another Roblox server
Profile:ListenToRelease(function()
player:Kick("Profile loaded elsewhere!")
end)
if player:IsDescendantOf(Players) then -- Profile has been successfully loaded
return Profile
else -- Player left before the profile loaded
Profile:Release()
end
else -- Profile couldn't be loaded
player:Kick("Plot failed to load. Please rejoin!")
end
end
and ideally, anytime the player selects a different plot, it should unload (save this plot) and then load in the other house.
Curious if the ListenToRelease is needed here? This is just code I’ve copied from the tutorial so unsure if that piece if necessary? Or if there’s a better way to achieve what I am after