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

Why wont my temp ban work I merged two scripts?

Asked by 3 years ago

I merged 2 scripts together for a temp ban but doesn't work

local Times = {
    One_Day = 86400; -- Seconds in a day
    Three_Days = 259200;  -- Seconds in 3 days
    One_Week = 604800;  -- Seconds in 1 week
}

local DataStoreService = game:GetService("DataStoreService")
local TempBanStore = DataStoreService:GetDataStore("TempBanStore",1)
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message)
        if message == "hi" then
            game.Players.PlayerAdded:Connect(function(Player)
                local Success, Result = pcall(function()
                    return TempBanStore:GetAsync(tostring(Player.UserId),"TempBan")
                end)

                if Success then
                    if Result then
                        if Result.BanStartTime + Result.BanTime > os.time() then
                            print("Player's temp ban is lifted")
                        else
                            player:Kick("You are temp-banned")
                        end
                    end
                end
            end)
        end
    end)
end)
0
The 2nd parameter of pcall is actually the error. Once it prints success, the result is basically useless. Dovydas1118 1495 — 3y

Answer this question