Everytime I load into a playtest and exit it roblox studio becomes unresponsive for a minute with nothing loaded then loads everything back and becomes responsive. it is not a hardware issue ive tried it on multiple networks and computers. When I disable my data storing script it unloads the playtest fine.
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Template = require(ReplicatedStorage.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local FormatSimple = require(ReplicatedStorage.Libs.FormatNumber.Simple)
local Cache = require(ReplicatedStorage.Libs.Cache)
local ProfileStore = ProfileService.GetProfileStore("Test", Template)
--Main one is Main
local KICK_MESSAGE = "Data issue, try again shortly. If issue persists it could be on our end stay tuned on our discord."
local function LoadProfile(player)
local profile = ProfileStore:LoadProfileAsync("Player_" .. player.UserId, "ForceLoad")
if not profile then
player:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
player:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) then
Manager.Profiles[player] = profile
local playerCache = Cache.new(player)
playerCache:Load(profile)
Cache[player] = playerCache
else
profile:Release()
end
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(player)
local profile = Manager.Profiles[player]
local playerCache = Cache[player]
if playerCache then
playerCache:Destroy()
Cache[player] = nil
end
if profile then
profile:Release()
end
end)