So I was attempting to learn profile service and after reading through the ProfileService forum and watching a video on it, I am left with this DataManager script:
local Players = game:GetService("Players")
local ProfileService = require(game.ReplicatedStorage.ProfileService)
local ProfileTemplate = {
money = 0,
lasetUsedMoneyPartTime = 0,
}
local ProfileStore = ProfileService.GetProfileStore(
"Player",
ProfileTemplate
)
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("Data Load Error")
end
end
local function onPlayerRemove(player)
local profile = Profiles[player]
if profile then
profile:Release()
end
end
Players.PlayerRemoving:Connect(onPlayerRemove)
Players.PlayerAdded:Connect(onPlayerAdded)
local DataManager = {}
function DataManager:Get(player)
local profile = Profiles[player]
if profile then
return profile.Data
end
end
return DataManager
However, I’m left with this in the console as a result:
09:47:56.753 ReplicatedStorage.ProfileService:1714: [ProfileService]: Profile template not set - ProfileStore:LoadProfileAsync() locked for this ProfileStore - Server - ProfileService:1714
Update:
I changed ProfileStore.LoadProfileAsync("Player_" .. player.UserId)
to ProfileStore.LoadProfileAsync(player.UserId)
and instead I was left with the error attempt to index number with '_profile_template'
leaving me to believe that the issue is definitely that the profile template I provided is for some reason not being received by the ProfileService module correctly?
I checked the api syntax for ProfileService and it seems that they do exactly what I do, and it should output the exact same as what I did. I even tried printing "Player_" .. player.UserId and I’m getting the correct output so I’m a still a bit lost here
local function onPlayerAdded(player)
print("Player_" .. player.UserId)
local profile = ProfileStore.LoadProfileAsync("Player_" .. player.UserId)
The error is showing on line 1713 of the ProfileService module, which is
if self._profile_template == nil then
error("[ProfileService]: Profile template not set - ProfileStore:LoadProfileAsync() locked for this ProfileStore")
end
and also showing on line 18 of the DataManager module script, line 18 is the ProfileStore.LoadProfileAsync("Player_" .. player.UserId)