When me and my friend play my game through roblox and we play on one server for some reason the code I have for profileService kicks me after a while, but everything loads so I dont understand why it would do that.
My friend never gets kicked but I always do.
When kicking me the message is “Data Service [ERROR 101]” so something is releasing my profile, but there just isnt anything I have done to release my profile after a while.
profileManagerModule
local function onProfileAdded(plr, profile): ()
serverModule = require(serverScriptService.serverService.serverModule)
task.spawn(_manager.updateLeaderstats, plr)
task.spawn(_manager.loadObjs, plr)
end
local profileStore = profileService.GetProfileStore(
"test1",
profileTemplate
)
function _manager:loadPlayerProfile(plr: Player): ()
local profile = profileStore:LoadProfileAsync("Player_" .. plr.UserId)
if profile ~= nil then
profile:AddUserId(plr.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
_manager.profiles[plr] = nil
plr:Kick("Data Service [ERROR 101]")
end)
if plr:IsDescendantOf(playerService) == true then
_manager.profiles[plr] = profile
onProfileAdded(plr, profile)
else
profile:Release()
end
else
plr:Kick("Data Service [ERROR 102]")
end
end
function _manager:ReleaseProfile(plr : Player): ()
if serverModule[plr.UserId] then
serverModule[plr.UserId] = nil
local profile = _manager.profiles[plr]
if profile ~= nil then
profile:Release()
end
end
end
profileMainScript
local playerService = game:GetService("Players")
local serverScriptService = game:GetService("ServerScriptService")
local profileFolder = serverScriptService.ProfileFolder
local _manager = require(profileFolder._ProfileManager)
local function onPlrAdded(plr: Player): ()
plr.CharacterAdded:Wait()
_manager:loadPlayerProfile(plr)
end
local function onPlrRemoving(plr: Player): ()
_manager:ReleaseProfile(plr)
end
for _, player in ipairs(playerService:GetPlayers()) do
task.spawn(onPlrAdded, player)
end
playerService.PlayerAdded:Connect(onPlrAdded)
playerService.PlayerRemoving:Connect(onPlrRemoving)
PLEASE HELP