For some reason, my DataStore isn’t working. It keeps saying that the player’s ban has expired, when it’s only been a few seconds or so. There are no errors in output, and I’m sure the CreateBan function is being called properly as I have used prints to debug.
local function CreateBan(Player,BanTime)
print(Player.Name)
print(BanTime)
local Success,Error = pcall(function()
if BanTime == "one_day" then
TempBanStore:SetAsync(Player.UserId,{BanStartTime = os.time(), BanTime = 86400})
Player:Kick("You have been temporarily banned from Bondi Rescue Roleplay for one day.")
elseif BanTime == "three_days" then
TempBanStore:SetAsync(Player.UserId,{BanStartTime = os.time(), BanTime = 259200})
Player:Kick("You have been temporarily banned from Bondi Rescue Roleplay for three days.")
elseif BanTime == "five_days" then
print("fivedaysbantime")
TempBanStore:SetAsync(Player.UserId,{BanStartTime = os.time(), BanTime = 432000})
Player:Kick("You have been temporarily banned from Bondi Rescue Roleplay for five days.")
end
end)
if not Success then
print("not success")
end
end
game.Players.PlayerAdded:Connect(function(Player)
local Success, Result = pcall(function()
return TempBanStore:GetAsync(Player.UserId,"TempBan")
end)
if Success then
if Result then
if Result.BanStartTime + Result.BanTime > os.time() then
TempBanStore:RemoveAsync(tostring(Player.UserId), "TempBan")
print("ban over")
else
Player:Kick("You have been temporarily banned from Bondi Rescue Roleplay.")
print("ban not over")
end
end
end
end)
game.ReplicatedStorage.AdminPanelEvent.OnServerEvent:Connect(function(plr, bantype,evidence,reason,username)
elseif bantype == "Temporary Bans - 5 Days" then
CreateBan(game.Players:FindFirstChild(username), "five_days")
local card = API:AddCard(username, "**"..bantype.."**".."\n\nUsername: "..username.."\n\nBanned By: "..plr.Name.."\n\nReason for Ban: "..reason.."\n\nEvidence: "..concattedevidence, ListID)
local cardid = API:GetCardID(username, BoardID)
API:PostComment(cardid, "Ban Added on "..months[ActualTime.month].." "..ActualTime.day..", "..ActualTime.year)
end
end)