Anything like what?
There shouldn’t be unless you use it improperly or in an unintended way.
Anything like what?
There shouldn’t be unless you use it improperly or in an unintended way.
I keep seeing this error when players join my game. Not all, but a lot of them, it even happened to me (i have a good internet connection and a decent computer).
Im guessing its not related to ProfileStore since the game doesn’t even load whatsoever but this is the only error im getting and its related to ProfileStore so im posting this here.
Any help will be appreciated!
Can you show us your ProfileStore code?
Main
local ServerStorage = game:GetService("ServerStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ProfileStore = require(ServerStorage.Scripts.ProfileStore)
local Manager = require(ServerScriptService.PlayerData.Manager)
local Template = require(ReplicatedStorage.Scripts.Template)
local Players = game:GetService("Players")
local PlayerStore = ProfileStore.New("Production2", Template)
local Profiles: {[player]: typeof(PlayerStore:StartSessionAsync())} = {}
local function CreateLeaderstats(Player: Player)
local profile = Manager.Profiles[Player]
if not profile then return end
local leaderstats = Instance.new("Folder", Player)
leaderstats.Name = "leaderstats"
local Extras = Instance.new("Folder")
Extras.Name = "Extras"
Extras.Parent = Player
local Kills = Instance.new("NumberValue", leaderstats)
Kills.Name = "Kills"
Kills.Value = profile.Data.Kills
local Berries = Instance.new("NumberValue", leaderstats)
Berries.Name = "Berries"
Berries.Value = profile.Data.Berries
local LastHit = Instance.new("StringValue")
LastHit.Name = "LastHit"
LastHit.Value = Template.LastHit
LastHit.Parent = Extras
local Settings = Instance.new("Folder")
Settings.Name = "Settings"
Settings.Parent = Player
for _, Value in ipairs(Template.Settings) do
if type(Value[2]) == "boolean" then
local ValueInstance = Instance.new("BoolValue")
ValueInstance.Name = Value[1]
if profile.Data[Value[1]] ~= nil then
ValueInstance.Value = profile.Data[Value[1]]
else
ValueInstance.Value = Value[2]
end
ValueInstance.Parent = Settings
elseif type(Value[2]) == "number" then
local ValueInstance = Instance.new("NumberValue")
ValueInstance.Name = Value[1]
if profile.Data[Value[1]] ~= nil then
ValueInstance.Value = profile.Data[Value[1]]
else
ValueInstance.Value = Value[2]
end
ValueInstance.Parent = Settings
elseif type(Value[2]) == "table" or type(Value[2]) == "string" then
local ValueInstance = Instance.new("StringValue")
ValueInstance.Name = Value[1]
if profile.Data[Value[1]] ~= nil then
ValueInstance.Value = tostring(profile.Data[Value[1]])
else
ValueInstance.Value = Value[2]
end
ValueInstance.Parent = Settings
end
end
end
local function PlayerAdded(player)
local profile = PlayerStore:StartSessionAsync(`{player.UserId}`, {
Cancel = function()
return player.Parent ~= Players
end,
})
if profile ~= nil then
profile:AddUserId(player.UserId)
profile:Reconcile()
profile.OnSessionEnd:Connect(function()
Manager.Profiles[player] = nil
player:Kick(`Profile session end - Please rejoin`)
end)
if player.Parent == Players then
Manager.Profiles[player] = profile
CreateLeaderstats(player)
else
profile:EndSession()
end
else
player:Kick(`Profile load fail - Please rejoin`)
end
end
-- In case Players have joined the server earlier than this script ran:
for _, player in Players:GetPlayers() do
task.spawn(PlayerAdded, player)
end
Players.PlayerAdded:Connect(PlayerAdded)
Players.PlayerRemoving:Connect(function(player)
local profile = Profiles[player]
if profile ~= nil then
profile:EndSession()
end
end)
Manager (Shortend for your sake)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes.Data
local ServerId = game.PrivateServerId
local Manager = {}
Manager.Profiles = {}
function Manager.AdjustKills(Player, Amount)
local Profile = Manager.Profiles[Player]
if not Profile or ServerId ~= "" then return end
Profile.Data.Kills += Amount
Player.leaderstats.Kills.Value = Profile.Data.Kills
Remotes.Kills:FireClient(Player, Profile.Data.Kills)
end
local function GetData(Player, Directory)
local Profile = Manager.Profiles[Player]
if not Profile then return end
return Profile.Data[Directory]
end
local function GetAllData(Player)
local Profile = Manager.Profiles[Player]
if not Profile then return end
return Profile.Data
end
Remotes.GetData.OnServerInvoke = GetData
Remotes.GetAllData.OnServerInvoke = GetAllData
return Manager