Help With profile service

My warning is

ServerScriptService.PlayerDataHandler:21: attempt to call missing method ‘LoadProfileAsync’ of table

I am not sure what the issue is here is my code

local PlayerDataHandler = {}

local ProfileStore = require(script.Parent:FindFirstChild(“BaseModules”):WaitForChild(“ProfileService”))
local dataTemplate = require(script:WaitForChild(“Attributes”))

local players = game:GetService(“Players”)

local profileStorage = ProfileStore.GetProfileStore(
“PlayerProfile”,
dataTemplate.Stats,
dataTemplate.Inventory,
dataTemplate.HotBar
)

local profiles = {}

dataTemplate:New()

local function PlayerAdded(player)
local profile = ProfileStore:LoadProfileAsync (“Player_”…player.UserId)

if profile then
	profile:AddUserId(player.UserId) -- loads profile 
	profile:Reconcile() 
	-------------------------------------------------------------------------------------
	profile:ListenToRelease(function()
		profile[player] = nil
		player:Kick()
		
	end)
	-------------------------------------------------------------------------------------
	if player:IsDecendantOf(players) then
        profiles[player] = profile 
        print(profiles[player].Data)
	else
		profile:Release()
	end
    --------------------------------------------------------------------------------------
else
    print("New Player")

end

end

function PlayerDataHandler:Init()
for _ , player in game.Players:GetPlayers() do
task.spawn(PlayerAdded, player)
end
game.Players.PlayerAdded:Connect(PlayerAdded)

game.Players.PlayerRemoving:Connect(function(player)
    if profiles[player] then
        profiles[player]:Release()
    end
end)

end

local function GetProfile (plr)
assert(profiles[plr], string.format(“Data does not exist for %s”… plr.UserId))
return profiles[plr]
end

–Get/Set Data

function PlayerDataHandler:Get (Player, data)

local profile = GetProfile(Player)
assert(profile.Data[data], string.format("Data does not exist for %s",data))

return profile.Data[data]

end

function PlayerDataHandler:Set (Player, data, value)
local profile = GetProfile(Player)
assert(profile.Data[data], string.format(“Data does not exist for %s”,data))
assert(type(profile.Data[data] == type(value)))

profile.Data[data] = value

end

function PlayerDataHandler:Update (Player, data, callBack)
local profile = GetProfile(Player)

local oldData =  self:Get(Player, data)
local newData = callBack(oldData)

self:Set(Player, data, newData)

end

return PlayerDataHandler


here is my set uip

image

There should be a line of code highlighted in the output window.

What line is being called out in the window?

1 Like

ServerScriptService.PlayerDataHandler:21: attempt to call missing method ‘LoadProfileAsync’ of table

This, is incorrect. You’re calling the ProfileService module directly to attempt to load data, instead you’d utilize the profileStorage Template. Which would then be this.

local profile = profileStorage:LoadProfileAsync (“Player_”…player.UserId)

This small error should be able to get you up & running.

2 Likes

Thanks I needed this working I appreciate it

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.