I’m creating a ban function.
I have tried the perm ban, and it works flawlessly.
But the problem lies in the non perm ban.
I get the error required_asset_8288681721.MainModule:90: attempt to concatenate table with string
.
My ban function looks like this:
function moonlightFramework.banPlayer(player, reason, datastoreName, perm, unixUnban)
local DataStoreService = game:GetService("DataStoreService")
local banDatastore = DataStoreService:GetDataStore(datastoreName)
if perm == true then
player:Kick("You have been banned forever for "..reason)
print("Sucessfully banned "..player.Name.." forever for "..reason..".")
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." is banned?", true)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." ban reason?", reason)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." ban forever?", perm)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
print("Success on data save!")
else
player:Kick("You have been banned until "..os.date("*t", unixUnban).." for "..reason)
print("Sucessfully banned "..player.Name.." until "..os.date("*t", unixUnban).." for "..reason..".")
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." is banned?", true)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." ban reason?", reason)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." ban forever?", perm)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
local success, errorMessage = pcall(function()
banDatastore:SetAsync(player.UserId.." unban time?", unixUnban)
end)
if not success then
warn("WARNING!!! Ban did not save! "..errorMessage)
end
print("Success on data save!")
end
end
-- i dont mind if anyone takes this
and my server script looks like:
local moon = require(8288681721)
wait(3)
moon.banPlayer(game.Players:WaitForChild("callmehSpear"), "hacking", "banDatabse2", false, 1639999783)
As I said, when the perm parameter is set to true, it all works fine, but when it is false and I give it a unix timestamp, it doesn’t.
Cheers for any help?