local PlayerDataManager = {}
local DataStoreService = game:GetService("DataStoreService")
local taps = DataStoreService:GetDataStore("Taps")
--Table to hold player data
local sessionData = {}
--Function to add player to sessionData
local function setupPlayerData(Player)
print("Test to setup")
end
--This function will save player data when they leave the game
local function saveOnExit(Player)
--We got in
--Saving Data when a player leaves
local success, errormassage = pcall(function()
taps:SetAsync ("Player_" .. Player.leaderstats.Taps.Value)
end)
if success then
print ("Player data was saved ")
else
print("There was an error when saving data")
warn (errormassage)-- this is the problem
end
end
game.Players.PlayerRemoving:Connect(saveOnExit)-- this will call the function when a player leaves
return PlayerDataManager
16:56:54.622 - Clicking(Beta) auto-recovery file was created
There was an error when saving data
16:57:06.559 - Argument 2 missing or nil
16:57:07.085 - Disconnect from ::ffff:127.0.0.1|59144
