Help me fix an Issue with profile service

I’m using Vectorthree (YouTuber) method of profile service, I followed him through out the video perfectly and I check again if I missed something, but I don’t think I did.

I’m getting this error message:

Attempt to call missing method ‘LoadProfileAsync’ of table

Not sure what’s causing it, I searched for the same error on the platform such as Help With profile service , but my code and theirs aren’t the same so I don’t understand what to change here.

Here is my code:

local PlayerDataHandler = {}

local dataTemplate = {
Coins = 0,
Inventory = {}
}

local RS = game:GetService("ReplicatedStorage")
local ProfileModule = require(RS.Data:WaitForChild("MainModule"))
local Players = game:GetService("Players")

local ProfileStore = ProfileModule.GetProfileStore(
"PlayerProfile",dataTemplate
)

local Profiles = {}

local function playerAdded(Player)
local Profile = ProfileModule:LoadProfileAsync("Player_"..Player.UserId)
if Profile then
Profile:AddUserId(Player.UserId)
Profile:Reconcile()

Profile:ListenToRelease(function()
Profile[Profile] = nil

Player:Kick()
end)

if not Player:IsDescendantOf(Players) then
Profile:Release()
else
Profiles[Player] = Profile
end
else
Player:Kick()
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(player)
assert(Profiles[player],string.format("Profile does not exist for %s",player.UserId))

return Profiles[player]
end

function PlayerDataHandler:Get(player,key)
local profile = getProfile(player)
assert(profile.Data[key], string.format("Data does not exist for key; %s",key))

return profile.Data[key]
end

function PlayerDataHandler:Set(player,key,value)
local profile = getProfile(player)
assert(profile.Data[key], string.format("Data does not exist for key; %s",key))

assert(type(profile.Data[key]) == type(value))

profile.Data[key] = value
end

function PlayerDataHandler:Update(player,key,callback)
local profile = getProfile(player)

local oldData = self:Get(player,key)
local newData = callback(oldData)

self:Set(player,key,newData)
end

return PlayerDataHandler

Please if you know what’s causing the issue or a solution to this, don’t resist to post it here, and please guide me through it, it’s 3AM for me and I’m using only one brain cell right now, Thanks!

Use ProfileStore instead of ProfileModule for LoadProfileAsync. Simple mistake, but a common one.

2 Likes

Yup I just realized, I for sure have one brain cell atm!

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