I am making a simple game using Profile Service, where there is a button that clears all of your data when you press it using the Wipe Profile Async, wheneaver i use it though, many errors appear:
Transform function error ServerScriptService.ProfileService:983: attempt to index nil with 'ActiveSession'
[ProfileService]: DataStore API error [Store:"Player";Key:"Player_1439024514"] - "Undefined error"
[ProfileService]: Entered critical state
Besides the errors, Roblox Studio halts for 20 seconds before going back to normal.
I am using this script to manage all the data from the Profile Service:
local Players = game:GetService("Players")
local ProfileService = require(script.Parent.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(
"Player",
{
endings = {1, 2, 3, 4}
}
)
local Profiles = {}
local function OnPlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync(
"Player_" .. player.UserId,
"ForceLoad"
)
if profile then
profile:ListenToRelease(function()
Profiles[player] = nil
player:Kick()
end)
if player:IsDescendantOf(Players) then
Profiles[player] = profile
else
profile:Release()
end
else
player:Kick()
end
end
local function OnPlayerRemoving(player)
local profile = Profiles[player]
if profile then
profile:Release()
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
function DataManager:ClearData(player) -- Where the player data is deleted.
ProfileStore:WipeProfileAsync("Player_" .. player.UserId)
end
return DataManager
Any help will be appreciated.