-
What do you want to achieve?
I just wanna detect if a bool is true. -
What is the issue?
I’m getting a error saying that the table that I’m getting the bool from is well nil. -
What solutions have you tried so far?
I’ve looked around the devForums a bit.
The script worked fine for days but all of the sudden, it stopped working
ServerStorage.SimpliCmd.Modules.Functions:18: attempt to index nil with ‘banned’ - Server - Functions:18
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("SimpliCmdBans10")
local SS = game:GetService("ServerStorage")
local cmds = require(script.Parent.Commands)
local module = {
CheckBan = function(plr)
local Id = plr.UserId
local banData
local success, warnd = pcall(function()
banData = DS:GetAsync(Id)
end)
if success then
if banData.banned then -- this is line 18
if banData.endTime == "Permanent" then
plr:Kick("\n Banned Permanently".."\n Reason: "..banData.reason)
return
end
if banData.endTime - os.time() <= 0 then
cmds.UnBan(plr)
print("Player unbanned")
return
end
local now = os.date("!*t", banData.endTime) -- "!*t" just means it's utc rather than local
local formatter = "%02i" -- formatter:format() will coerce a number to be a two-digit zero-padded str
-- for example, formatter:format(2) --> 02
local unBanTime = (formatter:format(now.month) .. "/" .. formatter:format(now.day) .. "/" .. now.year)
plr:Kick("\n Banned".."\n Reason: "..banData.reason.."\n Unban Date: \n"..unBanTime)
end
end
end,
}
return module