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

Argument 1 Missing Or Nil on a HTTP:JSONEncode() Value?

Asked by 4 years ago
Edited 4 years ago

So, I created an admin table and it saves. But, my DataStore only works when the DataStore name is "TestStore" and nothing else. If it's TestStore, it works, if it doesn't it gives me this error:

18:37:46.335 - Argument 1 missing or nil 18:37:46.336 - Stack Begin 18:37:46.336 - Script 'ServerScriptService.Test', Line 17 18:37:46.336 - Stack End 18:40:53.468 - Argument 2 missing or nil

This is the ServerScript inside of ServerScriptService:

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("ADifferentStore")
local HTTP = game:GetService("HttpService")

local admins = {}
local bans = {}

game.Players.PlayerAdded:Connect(function(player)
    local key = player.UserId

    local success, err = pcall(function()
        newList = DataStore:GetAsync(key.."-admins")
    end)

    if success then
        admins = newList
        local tableList = HTTP:JSONEncode(admins) --// Error Happens Here
        print(tableList)
        print("Admin Data Loaded")
    else
        warn(err.." | No Admin Data Found")
    end

end)

game.Players.PlayerRemoving:Connect(function(player)
    local key = player.UserId

    local success, err = pcall(function()
        DataStore:SetAsync(key.."-admins",admins)
    end)

    if err then
        warn(err)
    else
        print("Admin Data Saved")
    end
end)

The error happens on line 17. What is causing this error exactly?

0
Maybe it's was HTTPS:JSONEncode(admins) instead of HTTP:JSONEncode(admins). Xapelize 2658 — 4y
0
On line 3, I set HTTP equal to HttpService so I don't think that's the error. killerbrenden 1537 — 4y

Answer this question