Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

In my script it says Argument 2 missing or nil and i dont know how to fix it? [closed]

Asked by 3 years ago
Edited 3 years ago
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

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?