Profile Service Missing Or Invalid Name

So I have rewritten this profile service code a few time and I getting the same error code and still have not found out why I continue to get it. I haven’t require it in more that 1 script and I have Api enabled to prevent those bugs but this one in particular has had me stuck.

local PlayerDataManager = {}

local dataTemplate = {
    PowerLevel = 0,
    Ascension = 0,
    Invetory = {},
    
}


local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService("Players")

local ProfileStore = ProfileService:GetProfileStore(
    "PlayerStore",
    dataTemplate
)

local Profiles = {}

local function PlayerAdded(player)
    local Profile = ProfileStore:LoadProfileAsync("Player_" ..player.UseId)
    
    if Profile then
        Profile:AddUserId(player.UseId)
        Profile:Reconcile()
        
        Profile:ListenToRelease(function()
            Profiles[player] = nil
            
            player:Kick()
            
        end)
        
        if not player:IsDescendantOf(Players) then
            Profile:Release()
            
        else
            Profiles[player] = Profile
            
            print(Profile[player.Data])
        end
        
    else
        player:Kick()
        
    end
end

function PlayerDataManager: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)
    if not Profiles[player] then
        repeat task.wait(0.5)
            
        until Profiles[player]

    end
    
    assert(Profiles[player], string.format("Profile Does Not Exist for %s", player.UserId))
    
    return Profiles[player]
end

function PlayerDataManager:Get(player, key)
    local Profile = GetProfile(player)
    assert(Profiles[player], string.format("Data Does Not Exist For Key: %s", player.UserId))
    
    return Profile.Data[key]
    
end

function PlayerDataManager:Set(player, key, value)
    local Profile = GetProfile(player)
    
    assert(Profile.Data[key], string.format("Data Does Not Exist For Key: %s", player.UserId))
    
    assert(type(Profile.Data[key]) == type(value))
    
    Profile.Data[key] = value
    
end

function PlayerDataManager: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 PlayerDataManager

What error are you getting and what line?

Line 14, GetProfileStore uses a . not a :
Line 22 and Line 25, you spelled UserId as UseId
Line 41, you are trying to index Data from the player not the profile and you are missing an s

local PlayerDataManager = {}

local dataTemplate = {
	PowerLevel = 0,
	Ascension = 0,
	Invetory = {},

}


local ProfileService = require(game.ReplicatedStorage.ProfileService)
local Players = game:GetService("Players")

local ProfileStore = ProfileService.GetProfileStore(
	"PlayerStore",
	dataTemplate
)

local Profiles = {}

local function PlayerAdded(player)
	local Profile = ProfileStore:LoadProfileAsync("Player_" ..player.UserId)

	if Profile then
		Profile:AddUserId(player.UserId)
		Profile:Reconcile()

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

			player:Kick()

		end)

		if not player:IsDescendantOf(Players) then
			Profile:Release()

		else
			Profiles[player] = Profile

			print(Profiles[player].Data)
		end

	else
		player:Kick()

	end
end

function PlayerDataManager: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)
	if not Profiles[player] then
		repeat task.wait(0.5)

		until Profiles[player]

	end

	assert(Profiles[player], string.format("Profile Does Not Exist for %s", player.UserId))

	return Profiles[player]
end

function PlayerDataManager:Get(player, key)
	local Profile = GetProfile(player)
	assert(Profiles[player], string.format("Data Does Not Exist For Key: %s", player.UserId))

	return Profile.Data[key]

end

function PlayerDataManager:Set(player, key, value)
	local Profile = GetProfile(player)

	assert(Profile.Data[key], string.format("Data Does Not Exist For Key: %s", player.UserId))

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

	Profile.Data[key] = value

end

function PlayerDataManager: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 PlayerDataManager

I put in those patches you had said some obvious spelling error and the biggest problem was the : instead of the . Much appreciated How would you reccomended printing player data through the output i got an error on line 41 after fixing it

scratch this i figured out the problem

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