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
endfunction PlayerDataHandler:Init()
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(playerAdded, player)
endgame.Players.PlayerAdded:Connect(playerAdded)
game.Players.PlayerRemoving:Connect(function(player)
if Profiles[player] then
Profiles[player]:Release()
end
end)
endlocal 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]
endfunction 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
endfunction PlayerDataHandler:Update(player, key, callback)
local profile = getProfile(player)local oldData = self:Get(player, key)
local newData = callback(oldData)self:Set(player, key, newData)
endreturn PlayerDataHandler
Here is the script where I give the player the value
PlayerDataHandler:Update(player, "Logs", function(currentLogs)
return currentLogs + 2
end)