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)

1 comment

0

The 2nd parameter of pcall is actually the error. Once it prints success, the result is basically useless.