Profile Service ERROR!

I was watching this tutorial

I did everything they did, but when it came to testing. I got this error:

ServerScriptService.Modules.PlayerDataHandler:56: missing argument #2

Here is the main scripts

PlayerDataHandler (module script)

local PlayerDataHandler = {}

local dataTemplate = {
Logs = 0,
Stone = 0
}

local ProfileService = require(game.ServerScriptService:WaitForChild(“Modules”).ProfileService)
local Players = game:GetService(“Players”)

local ProfileStore = ProfileService.GetProfileStore(
“PlayerProfile”,
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
  end

else
player:Kick()
end
end

function PlayerDataHandler:Init()
for _, player in ipairs(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

– Getter/Setter methods
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

Here is the script where I give the player the value

		PlayerDataHandler:Update(player, "Logs", function(currentLogs)
			return currentLogs + 2
		end)
3 Likes

Can you specify which line is 56?

2 Likes

i did actually fix it, I misplaced a “)”

thanks for replying tho :smiley:

1 Like

Ohh, alright then!

1 Like

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